﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Text;
using netDxf;
using netDxf.Blocks;
using netDxf.Collections;
using netDxf.Entities;
using netDxf.Header;
using netDxf.Objects;
using netDxf.Tables;
using netDxf.Units;
using Attribute = netDxf.Entities.Attribute;
using Image = netDxf.Entities.Image;
using Point = netDxf.Entities.Point;
using Trace = netDxf.Entities.Trace;
 
namespace TestDxfDocument
{
    class DrillsAndCountersinkingToolsForIndexableInserts
    {
        public static void 
            TwistDrillForIndexableInsert(Dictionary<string, Object> data) //可转位麻花钻
        {
            DxfDocument dxf = new DxfDocument();
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);
            //作图
            //参数
            string path = Convert.ToString(data["path"]);
            double soal = Convert.ToDouble(data["oal"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0 && soal < 67)
            {
                scale = 4.0;
            }
            else if (scale == 0 && soal < 90)
            {
                scale = 3.0;
            }
            else if (scale == 0 && soal < 134)
            {
                scale = 2.0;
            }
            else if (scale == 0 && soal < 178)
            {
                scale = 1.5;
            }
            else if (scale == 0 && soal < 268)
            {
                scale = 1.0;
            }
            else if (scale == 0 && soal < 357)
            {
                scale = 0.75;
            }
            else if (scale == 0)
            {
                scale = 0.5;
            }
            double pi = Math.PI;
            double bd = Convert.ToDouble(data["bd"]) * scale;
            double dc = Convert.ToDouble(data["dc"]) * scale;
            double dconms = Convert.ToDouble(data["dconms"]) * scale;
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double ls = Convert.ToDouble(data["ls"]) * scale;
            double df = Convert.ToDouble(data["df"]) * scale;
            double flgt = Convert.ToDouble(data["flgt"]) * scale;
            double lcf = Convert.ToDouble(data["lcf"]) * scale;
            double rcf = Convert.ToDouble(data["rcf"]) * scale;
            double sig = Convert.ToDouble(data["sig"]) * pi / 180;
            double isframe = Convert.ToDouble(data["isframe"]);
            double pl = dc / 2 / Math.Tan(sig / 2);
            double lu = lcf - rcf;
            double lpr = oal - ls;
            double lf = lpr - pl;
            //坐标
            //主视图
            Vector2 v1 = new Vector2(dconms / 2 - 0.5, 0);
            Vector2 v2 = new Vector2(v1.X + 0.5, -0.5);
            Vector2 v3 = new Vector2(v2.X, -ls);
            Vector2 v4 = new Vector2(df / 2, v3.Y);
            Vector2 v5 = new Vector2(v4.X, v4.Y-flgt);
            Vector2 v6 = new Vector2(bd / 2, v5.Y);
            Vector2 v7 = new Vector2(v6.X, -oal + lcf);
            Vector2 v8 = new Vector2(v7.X-rcf, v7.Y-rcf);
            Vector2 v9 = new Vector2(v8.X, -oal+pl);
            Vector2 v10 = new Vector2(v7.X, v9.Y);
            Vector2 v11 = new Vector2(dc/2, v10.Y);
            Vector2 v12 = new Vector2(0, -oal);
            Vector2 v13 = new Vector2(-v11.X, v11.Y);
            Vector2 v14 = new Vector2(-v10.X, v10.Y);
            Vector2 v15 = new Vector2(-v9.X, v9.Y);
            Vector2 v16 = new Vector2(-v8.X, v8.Y);
            Vector2 v17 = new Vector2(-v7.X, v7.Y);
            Vector2 v18 = new Vector2(-v6.X, v6.Y);
            Vector2 v19 = new Vector2(-v5.X, v5.Y);
            Vector2 v20 = new Vector2(-v4.X, v4.Y);
            Vector2 v21 = new Vector2(-v3.X, v3.Y);
            Vector2 v22 = new Vector2(-v2.X, v2.Y);
            Vector2 v23 = new Vector2(-v1.X, v1.Y);
            Vector2 v24 = new Vector2(0, 2);
            Vector2 v25 = new Vector2(0, -oal - 2);
            Vector2 v26 = new Vector2(v13.X, v12.Y * 2 - v13.Y);
            Vector2 v27 = new Vector2(v11.X, v12.Y * 2 - v11.Y);
            //线段
            //主视图
            Vector2[] Line1 = { v1, v2 };
            fun.drawBLine(dxf, Line1, 0.3, contour);
            Vector2[] Line2 = { v2, v3 };
            fun.drawBLine(dxf, Line2, 0.3, contour);
            Vector2[] Line3 = { v3, v4 };
            fun.drawBLine(dxf, Line3, 0.3, contour);
            Vector2[] Line4 = { v4, v5 };
            fun.drawBLine(dxf, Line4, 0.3, contour);
            Vector2[] Line5 = { v5, v6 };
            fun.drawBLine(dxf, Line5, 0.3, contour);
            Vector2[] Line6 = { v6, v10 };
            fun.drawBLine(dxf, Line6, 0.3, contour);
            LwPolyline Arc7 = new LwPolyline();
            Arc7.Vertexes.Add(new LwPolylineVertex(v7));
            Arc7.Vertexes.Add(new LwPolylineVertex(v8));
            Arc7.Vertexes[0].Bulge = (1-Math.Cos(pi/4))* Math.Cos(pi / 4) * 2;
            fun.PolyFill(dxf, Arc7, 0.5, contour);
            Vector2[] Line8 = { v8, v9 };
            fun.drawBLine(dxf, Line8, 0.5, contour);
            Vector2[] Line9 = { v10, v14 };
            fun.drawBLine(dxf, Line9, 0.3, contour);
            Vector2[] Line10 = { v10, v11 };
            fun.drawPlinetype(dxf, Line10, 0.15, refin, Linetype.Dashed);
            Vector2[] Line11 = { v11, v12 };
            fun.drawPlinetype(dxf, Line11, 0.15, refin, Linetype.Dashed);
            Vector2[] Line12 = { v12, v13 };
            fun.drawPlinetype(dxf, Line12, 0.15, refin, Linetype.Dashed);
            Vector2[] Line13 = { v13, v14 };
            fun.drawPlinetype(dxf, Line13, 0.15, refin, Linetype.Dashed);
            Vector2[] Line14 = { v14, v17 };
            fun.drawBLine(dxf, Line14, 0.3, contour);
            Vector2[] Line15 = { v15, v16 };
            fun.drawPlinetype(dxf, Line15, 0.15, refin, Linetype.Dashed);
            /*LwPolyline Arc16 = new LwPolyline();
            Arc16.Vertexes.Add(new LwPolylineVertex(v16));
            Arc16.Vertexes.Add(new LwPolylineVertex(v17));
            Arc16.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * Math.Cos(pi / 4) * 2;
            fun.PolyFillandlinetype(dxf, Arc16, 0, refin, Linetype.Center);*/
            Vector2[] Line17 = { v17, v18 };
            fun.drawBLine(dxf, Line17, 0.3, contour);
            Vector2[] Line18 = { v18, v19 };
            fun.drawBLine(dxf, Line18, 0.3, contour);
            Vector2[] Line19 = { v19, v20 };
            fun.drawBLine(dxf, Line19, 0.3, contour);
            Vector2[] Line20 = { v20, v21 };
            fun.drawBLine(dxf, Line20, 0.3, contour);
            Vector2[] Line21 = { v21, v22 };
            fun.drawBLine(dxf, Line21, 0.3, contour);
            Vector2[] Line22 = { v22, v23 };
            fun.drawBLine(dxf, Line22, 0.3, contour);
            Vector2[] Line23 = { v23, v1 };
            fun.drawBLine(dxf, Line23, 0.3, contour);
            Vector2[] Line24 = { v22, v2 };
            fun.drawBLine(dxf, Line24, 0.3, contour);
            Vector2[] Line25 = { v21, v3 };
            fun.drawBLine(dxf, Line25, 0.3, contour);
            Vector2[] Line26 = { v18, v6 };
            fun.drawBLine(dxf, Line26, 0.3, contour);
            Vector2[] Line27 = { v24, v25 };
            fun.drawPlinetype(dxf, Line27, 0.15, center, Linetype.Center);
            Arc arc28 = new Arc(new Vector2(v7.X,v8.Y), rcf, 90, 180);
            Line Line29 = new Line(v12, v26);
            Line Line30 = new Line(v12, v27);
            Arc arc31 = new Arc(new Vector2(v17.X, v16.Y), rcf, 0, 90);
            Line29.Layer = dimensioning;
            Line30.Layer = dimensioning;
            arc31.Layer = refin;
            arc31.Linetype = Linetype.Dashed;
            dxf.AddEntity(Line29);
            dxf.AddEntity(Line30);
            dxf.AddEntity(arc31);
            //标注样式
            //箭头样式
            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 0.2;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            //文本样式
            dimensionStyle.TextHeight = 1.0;
            double offset = 10;
            //线段尺寸标注
            //尺寸1
            LinearDimension dim1 = new LinearDimension(new Line(v19, v20), -offset, 270, dimensionStyle);
            dim1.UserText = "FLGT = " + Math.Round(flgt / scale, 2);
            dxf.AddEntity(dim1);
            //尺寸2
            LinearDimension dim2 = new LinearDimension(new Line(v11, v13), -offset*2-pl-20, 0, dimensionStyle);
            dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
            dxf.AddEntity(dim2);
            //尺寸3
            LinearDimension dim3 = new LinearDimension(new Line(v20, v13), -offset*2 - (v13.X - v20.X) / 2, 270, dimensionStyle);
            dim3.UserText = "LF = " + Math.Round(lf / scale, 2);
            dxf.AddEntity(dim3);
            //尺寸4
            LinearDimension dim4 = new LinearDimension(new Line(v20, v23), -offset*3 - (v23.X - v20.X) / 2, 270, dimensionStyle);
            dim4.UserText = "LS = " + Math.Round(ls / scale, 2);
            dxf.AddEntity(dim4);
            //尺寸5
            LinearDimension dim5 = new LinearDimension(new Line(v12, v1), offset * 3 + v4.X - v1.X / 2, 270, dimensionStyle);
            dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
            dxf.AddEntity(dim5);
            //尺寸6
            LinearDimension dim6 = new LinearDimension(new Line(v22, v2), offset + 0.5, 0, dimensionStyle);
            dim6.UserText = "DCONMS = " + Math.Round(dconms / scale, 2);
            dxf.AddEntity(dim6);
            //尺寸7
            LinearDimension dim7 = new LinearDimension(new Line(v20, v4), offset*2 + v1.Y-v4.Y, 0, dimensionStyle);
            dim7.UserText = "DF = " + Math.Round(df / scale, 2);
            dxf.AddEntity(dim7);
            //尺寸8
            LinearDimension dim8 = new LinearDimension(new Line(v10, v14), -offset*2-pl-10, 0, dimensionStyle);
            dim8.UserText = "BD = " + Math.Round(bd / scale, 2);
            dxf.AddEntity(dim8);
            //尺寸9
            LinearDimension dim9 = new LinearDimension(new Line(v12, v20), -offset * 3 + v20.X / 2, 270, dimensionStyle);
            dim9.UserText = "LPR = " + Math.Round(lpr / scale, 2);
            dxf.AddEntity(dim9);
            //尺寸10
            LinearDimension dim10 = new LinearDimension(new Line(v12, v8), offset + v8.X / 2+v4.X-v8.X, 270, dimensionStyle);
            dim10.UserText = "LU = " + Math.Round(lu / scale, 2);
            dxf.AddEntity(dim10);
            //尺寸11
            LinearDimension dim11 = new LinearDimension(new Line(v12, v7), offset * 2 + v7.X / 2+v4.X-v7.X, 270, dimensionStyle);
            dim11.UserText = "LCF = " + Math.Round(lcf / scale, 2);
            dxf.AddEntity(dim11);
            //尺寸12
            LinearDimension dim12 = new LinearDimension(new Line(v12, v11), offset/2 + v11.X / 2 + v4.X - v11.X, 270, dimensionStyle);
            dim12.UserText = "PL = " + Math.Round(pl / scale, 2);
            dxf.AddEntity(dim12);
            //尺寸13
            RadialDimension dimrad13 = new RadialDimension(arc28, 135, -rcf+5, dimensionStyle);//DimensionStyle.Default);
            dimrad13.UserText = "RCF = " + Math.Round(rcf / scale, 2);
            dxf.AddEntity(dimrad13);
            //尺寸14
            Angular2LineDimension angdim14 = new Angular2LineDimension(Line29, Line30, offset, dimensionStyle);
            angdim14.UserText = "SIG = " + Math.Round(sig / pi * 180, 2) + "°";
            dxf.AddEntity(angdim14);
            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(-148.5, 210 - oal / 2));
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            //定义格式，根据路径导出

            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
        public static void StepDrillForIndexableInsert(Dictionary<string, Object> data)//可转位阶梯钻
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);

            //作图
            //参数
            string path = Convert.ToString(data["path"]);
            double soal = Convert.ToDouble(data["oal"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0 && soal < 67)
            {
                scale = 4.0;
            }
            else if (scale == 0 && soal < 90)
            {
                scale = 3.0;
            }
            else if (scale == 0 && soal < 134)
            {
                scale = 2.0;
            }
            else if (scale == 0 && soal < 178)
            {
                scale = 1.5;
            }
            else if (scale == 0 && soal < 268)
            {
                scale = 1.0;
            }
            else if (scale == 0 && soal < 357)
            {
                scale = 0.75;
            }
            else if (scale == 0)
            {
                scale = 0.5;
            }
            double pi = Math.PI;
            double dc1 = Convert.ToDouble(data["dc1"]) * scale;
            double dc2 = Convert.ToDouble(data["dc2"]) * scale;
            double dc3 = Convert.ToDouble(data["dc3"]) * scale;
            double dc4 = Convert.ToDouble(data["dc4"]) * scale;
            double bd1 = Convert.ToDouble(data["bd1"]) * scale;
            double bd2 = Convert.ToDouble(data["bd2"]) * scale;
            double bd3 = Convert.ToDouble(data["bd3"]) * scale;
            double bd4 = Convert.ToDouble(data["bd4"]) * scale;
            double sdl1 = Convert.ToDouble(data["sdl1"]) * scale;
            double sd4 = Convert.ToDouble(data["sd4"]) * scale;
            double sd3 = Convert.ToDouble(data["sd3"]) * scale;
            double sta2 = Convert.ToDouble(data["sta2"]) * pi / 180;
            double sta3 = Convert.ToDouble(data["sta3"]) * pi / 180;
            double sta4 = Convert.ToDouble(data["sta4"]) * pi / 180;
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double dconms = Convert.ToDouble(data["dconms"]) * scale;
            double ls = Convert.ToDouble(data["ls"]) * scale;
            double sig = Convert.ToDouble(data["sig"]) * pi / 180;
            double df = Convert.ToDouble(data["df"]) * scale;
            double flgt = Convert.ToDouble(data["flgt"]) * scale;
            double lcf = Convert.ToDouble(data["lcf"]) * scale;
            double rcf = Convert.ToDouble(data["rcf"]) * scale;
            double nos = Convert.ToDouble(data["nos"]);
            double pl = dc1 / 2 / Math.Tan(sig / 2);
            double lpr = oal - ls;
            double isframe = Convert.ToDouble(data["isframe"]);
            //主视图
            if (nos == 4)
            {
                //坐标
                Vector2 v1 = new Vector2(dconms / 2 - 0.5, 0);
                Vector2 v2 = new Vector2(dconms / 2, -0.5);
                Vector2 v3 = new Vector2(v2.X, -ls);
                Vector2 v4 = new Vector2(df / 2, v3.Y);
                Vector2 v5 = new Vector2(v4.X, v4.Y-flgt);
                Vector2 v6 = new Vector2(bd4 / 2, v5.Y);
                Vector2 v7 = new Vector2(v6.X, -oal + lcf);
                Vector2 v8 = new Vector2(v7.X-rcf, v7.Y - rcf);
                Vector2 v9 = new Vector2(v8.X, -oal + pl);
                Vector2 v10 = new Vector2(v7.X, -oal+sd4+(dc4-bd4)/2*Math.Tan(sta4/2));
                Vector2 v11 = new Vector2(dc4/2, -oal+sd4);
                Vector2 v33 = new Vector2(v10.X, v11.Y);
                Vector2 v34 = new Vector2(bd3 / 2, v33.Y - (bd4 - bd3) / 2 / Math.Tan(sta4 / 2));
                Vector2 v12 = new Vector2(dc3/2, v34.Y - (v11.X-v33.X-(dc3 - bd3) / 2) / Math.Tan(sta4 / 2));
                Vector2 v35 = new Vector2(v34.X, -oal + sd3);
                Vector2 v13 = new Vector2(v12.X, (v12.X-v34.X-(dc2-bd2)/2)/Math.Tan(sta3/2)+v35.Y);
                Vector2 v36 = new Vector2(bd2 / 2, v35.Y - (bd3 - bd2) / 2 / Math.Tan(sta3 / 2));
                Vector2 v14 = new Vector2(dc2/2, v36.Y);
                Vector2 v37 = new Vector2(v36.X, -oal + pl + sdl1+(bd2-bd1)/2* Math.Cos(sta2 / 2)/ Math.Sin(sta2 / 2));
                Vector2 v15 = new Vector2(v14.X, v37.Y-v14.X+v36.X);
                Vector2 v38 = new Vector2(bd1 / 2, -oal + pl + sdl1);
                Vector2 v16 = new Vector2(dc1 / 2, v15.Y - (dc2 - dc1) / 2 / Math.Tan(sta2 / 2));
                Vector2 v39 = new Vector2(v38.X, -oal + pl);
                Vector2 v17 = new Vector2(v16.X, v39.Y);
                Vector2 v18 = new Vector2(0, -oal);
                Vector2 v19 = new Vector2(-v17.X, v17.Y);
                Vector2 v20 = new Vector2(-v16.X, v16.Y);
                Vector2 v21 = new Vector2(-v15.X, v15.Y);
                Vector2 v22 = new Vector2(-v14.X, v14.Y);
                Vector2 v23 = new Vector2(-v13.X, v13.Y);
                Vector2 v24 = new Vector2(-v12.X, v12.Y);
                Vector2 v25 = new Vector2(-v11.X, v11.Y);
                Vector2 v26 = new Vector2(-v10.X, v10.Y);
                Vector2 v27 = new Vector2(-v6.X, v6.Y);
                Vector2 v28 = new Vector2(-v5.X, v5.Y);
                Vector2 v29 = new Vector2(-v4.X, v4.Y);
                Vector2 v30 = new Vector2(-v3.X, v3.Y);
                Vector2 v31 = new Vector2(-v2.X, v2.Y);
                Vector2 v32 = new Vector2(-v1.X, v1.Y);
                Vector2 v40 = new Vector2(-v39.X, v39.Y);
                Vector2 v41 = new Vector2(-v38.X, v38.Y);
                Vector2 v42 = new Vector2(-v37.X, v37.Y);
                Vector2 v43 = new Vector2(-v36.X, v36.Y);
                Vector2 v44 = new Vector2(-v35.X, v35.Y);
                Vector2 v45 = new Vector2(-v34.X, v34.Y);
                Vector2 v46 = new Vector2(-v33.X, v33.Y);
                Vector2 v47 = new Vector2(0, 2);
                Vector2 v48 = new Vector2(0, -oal - 2);
                Vector2 v49 = new Vector2(v19.X, 2 * v18.Y - v19.Y);
                Vector2 v50 = new Vector2(v17.X, 2 * v18.Y - v17.Y);
                double x51 = bd4 / 2 - rcf;
                if (v46.Y>v8.Y)
                {
                    x51 = v6.X - Math.Sqrt(rcf * rcf - (v46.Y - v8.Y) * (v46.Y - v8.Y));
                }
                double x52 = bd4 / 2 - rcf;
                if (v45.Y > v8.Y)
                {
                    x52 = v6.X - Math.Sqrt(rcf * rcf - (v45.Y - v8.Y) * (v45.Y - v8.Y));
                }
                double x53 = bd4 / 2 - rcf;
                if (v44.Y > v8.Y)
                {
                    x53 = v6.X - Math.Sqrt(rcf * rcf - (v44.Y - v8.Y) * (v44.Y - v8.Y));
                }
                double x54 = bd4 / 2 - rcf;
                if (v43.Y > v8.Y)
                {
                    x54 = v6.X - Math.Sqrt(rcf * rcf - (v43.Y - v8.Y) * (v43.Y - v8.Y));
                }
                double x55 = bd4 / 2 - rcf;
                if (v41.Y > v8.Y)
                {
                    x55 = v6.X - Math.Sqrt(rcf * rcf - (v41.Y - v8.Y) * (v41.Y - v8.Y));
                }
                double x56 = bd4 / 2 - rcf;
                if (v42.Y > v8.Y)
                {
                    x56 = v6.X - Math.Sqrt(rcf * rcf - (v42.Y - v8.Y) * (v42.Y - v8.Y));
                }
                Vector2 v51 = new Vector2(x51, v46.Y);
                Vector2 v52 = new Vector2(x52, v45.Y);
                Vector2 v53 = new Vector2(x53, v44.Y);
                Vector2 v54 = new Vector2(x54, v43.Y);
                Vector2 v55 = new Vector2(x55, v41.Y);
                Vector2 v56 = new Vector2(x56, v42.Y);
                //线段
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                Vector2[] Line3 = { v3, v4 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v4, v5 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v5, v6 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v6, v33 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                Vector2[] Line7 = { v33, v34 };
                fun.drawBLine(dxf, Line7, 0.3, contour);
                Vector2[] Line8 = { v34, v35 };
                fun.drawBLine(dxf, Line8, 0.3, contour);
                Vector2[] Line9 = { v35, v36 };
                fun.drawBLine(dxf, Line9, 0.3, contour);
                Vector2[] Line10 = { v36, v37 };
                fun.drawBLine(dxf, Line10, 0.3, contour);
                Vector2[] Line11 = { v37, v38 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
                Vector2[] Line12 = { v38, v39 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line13 = { v10, v11 };
                fun.drawPlinetype(dxf, Line13, 0.15, refin, Linetype.Dashed);
                Vector2[] Line14 = { v11, v12 };
                fun.drawPlinetype(dxf, Line14, 0.15, refin, Linetype.Dashed);
                Vector2[] Line15 = { v12, v13 };
                fun.drawPlinetype(dxf, Line15, 0.15, refin, Linetype.Dashed);
                Vector2[] Line16 = { v13, v14 };
                fun.drawPlinetype(dxf, Line16, 0.15, refin, Linetype.Dashed);
                Vector2[] Line17 = { v14, v15 };
                fun.drawPlinetype(dxf, Line17, 0.15, refin, Linetype.Dashed);
                Vector2[] Line18 = { v15, v16 };
                fun.drawPlinetype(dxf, Line18, 0.15, refin, Linetype.Dashed);
                Vector2[] Line19 = { v16, v17 };
                fun.drawPlinetype(dxf, Line19, 0.15, refin, Linetype.Dashed);
                Vector2[] Line20 = { v17, v39 };
                fun.drawPlinetype(dxf, Line20, 0.15, refin, Linetype.Dashed);
                Vector2[] Line21 = { v39, v40 };
                fun.drawBLine(dxf, Line21, 0.3, contour);
                Vector2[] Line22 = { v17, v18 };
                fun.drawPlinetype(dxf, Line22, 0.15, refin, Linetype.Dashed);
                Vector2[] Line23 = { v18, v19 };
                fun.drawPlinetype(dxf, Line23, 0.15, refin, Linetype.Dashed);
                Vector2[] Line24 = { v19, v40 };
                fun.drawPlinetype(dxf, Line24, 0.15, refin, Linetype.Dashed);
                Vector2[] Line25 = { v19, v20 };
                fun.drawPlinetype(dxf, Line25, 0.15, refin, Linetype.Dashed);
                Vector2[] Line26 = { v20, v21 };
                fun.drawPlinetype(dxf, Line26, 0.15, refin, Linetype.Dashed);
                Vector2[] Line27 = { v21, v22 };
                fun.drawPlinetype(dxf, Line27, 0.15, refin, Linetype.Dashed);
                Vector2[] Line28 = { v22, v23 };
                fun.drawPlinetype(dxf, Line28, 0.15, refin, Linetype.Dashed);
                Vector2[] Line29 = { v23, v24 };
                fun.drawPlinetype(dxf, Line29, 0.15, refin, Linetype.Dashed);
                Vector2[] Line30 = { v24, v25 };
                fun.drawPlinetype(dxf, Line30, 0.15, refin, Linetype.Dashed);
                Vector2[] Line31 = { v25, v26 };
                fun.drawPlinetype(dxf, Line31, 0.15, refin, Linetype.Dashed);
                Vector2[] Line32 = { v27, v46 };
                fun.drawBLine(dxf, Line32, 0.3, contour);
                Vector2[] Line33 = { v46, v45 };
                fun.drawBLine(dxf, Line33, 0.3, contour);
                Vector2[] Line34 = { v45, v44 };
                fun.drawBLine(dxf, Line34, 0.3, contour);
                Vector2[] Line35 = { v44, v43 };
                fun.drawBLine(dxf, Line35, 0.3, contour);
                Vector2[] Line36 = { v43, v42 };
                fun.drawBLine(dxf, Line36, 0.3, contour);
                Vector2[] Line37 = { v42, v41 };
                fun.drawBLine(dxf, Line37, 0.3, contour);
                Vector2[] Line38 = { v41, v40 };
                fun.drawBLine(dxf, Line38, 0.3, contour);
                Vector2[] Line39 = { v27, v28 };
                fun.drawBLine(dxf, Line39, 0.3, contour);
                Vector2[] Line40 = { v28, v29 };
                fun.drawBLine(dxf, Line40, 0.3, contour);
                Vector2[] Line41 = { v29, v30 };
                fun.drawBLine(dxf, Line41, 0.3, contour);
                Vector2[] Line42 = { v30, v31 };
                fun.drawBLine(dxf, Line42, 0.3, contour);
                Vector2[] Line43 = { v31, v32 };
                fun.drawBLine(dxf, Line43, 0.3, contour);
                Vector2[] Line44 = { v32, v1 };
                fun.drawBLine(dxf, Line44, 0.3, contour);
                Vector2[] Line45 = { v31, v2 };
                fun.drawBLine(dxf, Line45, 0.3, contour);
                Vector2[] Line46 = { v30, v3 };
                fun.drawBLine(dxf, Line46, 0.3, contour);
                Vector2[] Line47 = { v27, v6 };
                fun.drawBLine(dxf, Line47, 0.3, contour);
                Vector2[] Line48 = { v46, v51 };
                fun.drawBLine(dxf, Line48, 0.3, contour);
                Vector2[] Line49 = { v45, v52 };
                fun.drawBLine(dxf, Line49, 0.3, contour);
                Vector2[] Line50 = { v44, v53 };
                fun.drawBLine(dxf, Line50, 0.3, contour);
                Vector2[] Line51 = { v43, v54 };
                fun.drawBLine(dxf, Line51, 0.3, contour);
                Vector2[] Line52 = { v41, v55 };
                fun.drawBLine(dxf, Line52, 0.3, contour);
                Vector2[] Line53 = { v47, v48 };
                fun.drawPlinetype(dxf, Line53, 0.15, center, Linetype.Center);
                Line Line54 = new Line(v18, v49);
                Line Line55 = new Line(v18, v50);
                Vector2[] Line56 = { v8, v9 };
                fun.drawBLine(dxf, Line56, 0.3, contour);
                Vector2[] Line57 = { v42, v56 };
                fun.drawBLine(dxf, Line57, 0.3, contour);
                LwPolyline Arc1 = new LwPolyline();
                Arc1.Vertexes.Add(new LwPolylineVertex(v7));
                Arc1.Vertexes.Add(new LwPolylineVertex(v8));
                Arc1.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * 2 * Math.Cos(pi / 4);
                fun.PolyFill(dxf, Arc1, 0.3, contour);
                Arc Arc2 = new Arc(new Vector2(v7.X, v8.Y), rcf, 90, 180);
                //主视图图层
                Line54.Layer = dimensioning;
                Line55.Layer = dimensioning;
                //主视图
                dxf.AddEntity(Line54);
                dxf.AddEntity(Line55);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 1.0;
                double offset = 10;
                //线段尺寸标注
                //尺寸1
                Angular2LineDimension angdim1 = new Angular2LineDimension(Line54, Line55, offset / 2, dimensionStyle);
                angdim1.UserText = "SIG = " + Math.Round(sig / (pi / 180), 2) + "°";
                dxf.AddEntity(angdim1);
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(v17, v19), -pl - offset - 10, 0, dimensionStyle);
                dim2.UserText = "DC_1 = " + Math.Round(dc1 / scale, 2);
                dxf.AddEntity(dim2);
                //尺寸3
                LinearDimension dim3 = new LinearDimension(new Line(v15, v21), -v15.Y+v18.Y - offset*2-10, 0, dimensionStyle);
                dim3.UserText = "DC_2 = " + Math.Round(dc2 / scale, 2);
                dxf.AddEntity(dim3);
                //尺寸4
                LinearDimension dim4 = new LinearDimension(new Line(v13, v23), -v13.Y + v18.Y - offset * 3-10, 0, dimensionStyle);
                dim4.UserText = "DC_3 = " + Math.Round(dc3 / scale, 2);
                dxf.AddEntity(dim4);
                //尺寸5
                LinearDimension dim5 = new LinearDimension(new Line(v18, v19), -offset - v4.X + v17.X / 2, 270, dimensionStyle);
                dim5.UserText = "PL = " + Math.Round(pl / scale, 2);
                dxf.AddEntity(dim5);
                //尺寸6
                LinearDimension dim6 = new LinearDimension(new Line(v1, v3), offset + 0.25+v4.X-v3.X, 270, dimensionStyle);
                dim6.UserText = "LS = " + Math.Round(ls / scale, 2);
                dxf.AddEntity(dim6);
                //尺寸7
                LinearDimension dim7 = new LinearDimension(new Line(v41, v19), -offset - (v4.X-(v38.X+v17.X)/2), 270, dimensionStyle);
                dim7.UserText = "SDL_1 = " + Math.Round(sdl1 / scale, 2);
                dxf.AddEntity(dim7);
                //尺寸8
                LinearDimension dim8 = new LinearDimension(new Line(v35, v18), offset + v4.X-v35.X/2, 270, dimensionStyle);
                dim8.UserText = "SD_3 = " + Math.Round(sd3 / scale, 2);
                dxf.AddEntity(dim8);
                //尺寸9
                LinearDimension dim9 = new LinearDimension(new Line(v18, v1), offset * 5 +v4.X - v1.X / 2+0.25, 270, dimensionStyle);
                dim9.UserText = "OAL = " + Math.Round(oal / scale, 2);
                dxf.AddEntity(dim9);
                //尺寸10
                LinearDimension dim10 = new LinearDimension(new Line(v31, v2), offset + 0.5, 0, dimensionStyle);
                dim10.UserText = "DCONMS = " + Math.Round(dconms / scale, 2);
                dxf.AddEntity(dim10);
                //尺寸11
                if (sta2 != pi)
                {
                    Angular2LineDimension angdim11 = new Angular2LineDimension(new Line(v41, v42), new Line(v38, v37), v38.X / Math.Sin(sta2 / 2) * Math.Cos(sta2 / 2) + offset-5, dimensionStyle);
                    angdim11.UserText = "STA_2 = " + Math.Round(sta2 / (pi / 180), 2) + "°";
                    dxf.AddEntity(angdim11);
                }
                if (sta2 == pi)
                {
                    Angular2LineDimension angdim11 = new Angular2LineDimension(new Line(v41, new Vector2(v42.X,v42.Y+0.1)), new Line(v38, new Vector2(v37.X, v37.Y + 0.1)), v38.X / Math.Sin(sta2 / 2) * Math.Cos(sta2 / 2) + offset-5, dimensionStyle);
                    angdim11.UserText = "STA_2 = " + Math.Round(sta2 / (pi / 180), 2) + "°";
                    dxf.AddEntity(angdim11);
                }
                //尺寸12
                /*Angular2LineDimension angdim12 = new Angular2LineDimension(new Line(v43, v44), new Line(v36, v35), v36.X / Math.Sin(sta3 / 2)* Math.Cos(sta3 / 2) + offset, dimensionStyle);
                angdim12.UserText = "STA_3 = " + Math.Round(sta3 / (pi / 180), 2) + "°";
                dxf.AddEntity(angdim12);*/
                if (sta3 != pi)
                {
                    Angular2LineDimension angdim12 = new Angular2LineDimension(new Line(v43, v44), new Line(v36, v35), v36.X / Math.Sin(sta3 / 2) * Math.Cos(sta3 / 2) + offset, dimensionStyle);
                    angdim12.UserText = "STA_3 = " + Math.Round(sta3 / (pi / 180), 2) + "°";
                    dxf.AddEntity(angdim12);
                }
                if (sta3 == pi)
                {
                    Angular2LineDimension angdim12 = new Angular2LineDimension(new Line(v43, new Vector2(v44.X, v44.Y + 0.1)), new Line(v36, new Vector2(v35.X, v35.Y + 0.1)), v36.X / Math.Sin(sta3 / 2) * Math.Cos(sta3 / 2) + offset, dimensionStyle);
                    angdim12.UserText = "STA_3 = " + Math.Round(sta3 / (pi / 180), 2) + "°";
                    dxf.AddEntity(angdim12);
                }
                //尺寸13
                LinearDimension dim13 = new LinearDimension(new Line(v11, v25), -v11.Y + v18.Y - offset * 3-30, 0, dimensionStyle);
                dim13.UserText = "DC_4 = " + Math.Round(dc4 / scale, 2);
                dxf.AddEntity(dim13);
                //尺寸14
                LinearDimension dim14 = new LinearDimension(new Line(v33, v18), offset*2 + v4.X - v33.X / 2, 270, dimensionStyle);
                dim14.UserText = "SD_4 = " + Math.Round(sd4 / scale, 2);
                dxf.AddEntity(dim14);
                //尺寸15
                Angular2LineDimension angdim15 = new Angular2LineDimension(new Line(v45, v46), new Line(v34, v33), v34.X/Math.Sin(sta4/2) * Math.Cos(sta3 / 2) + offset+10, dimensionStyle);
                angdim15.UserText = "STA_4 = " + Math.Round(sta4 / (pi / 180), 2) + "°";
                dxf.AddEntity(angdim15);
                //尺寸16
                LinearDimension dim16 = new LinearDimension(new Line(v4, v5), offset, 270, dimensionStyle);
                dim16.UserText = "FLGT = " + Math.Round(flgt / scale, 2);
                dxf.AddEntity(dim16);
                //尺寸17
                LinearDimension dim17 = new LinearDimension(new Line(v7, v18), offset*3 - v7.X/2 + v4.X, 270, dimensionStyle);
                dim17.UserText = "LCF = " + Math.Round(lcf / scale, 2);
                dxf.AddEntity(dim17);
                //尺寸18
                LinearDimension dim18 = new LinearDimension(new Line(v4, v18), offset*4 + v4.X/2, 270, dimensionStyle);
                dim18.UserText = "LPR = " + Math.Round(lpr / scale, 2);
                dxf.AddEntity(dim18);
                //尺寸19
                LinearDimension dim19 = new LinearDimension(new Line(v29, v4), -flgt/2, 0, dimensionStyle);
                dim19.UserText = "DF = " + Math.Round(df / scale, 2);
                dxf.AddEntity(dim19);
                //尺寸20
                LinearDimension dim20 = new LinearDimension(new Line(v27, v6), -(v27.Y-v46.Y)/2, 0, dimensionStyle);
                dim20.UserText = "BD_4 = " + Math.Round(bd4 / scale, 2);
                dxf.AddEntity(dim20);
                //尺寸21
                LinearDimension dim21 = new LinearDimension(new Line(v45, v34), -(v45.Y - v44.Y) / 2, 0, dimensionStyle);
                dim21.UserText = "BD_3 = " + Math.Round(bd3 / scale, 2);
                dxf.AddEntity(dim21);
                //尺寸22
                LinearDimension dim22 = new LinearDimension(new Line(v43, v36), -(v43.Y - v42.Y) / 2, 0, dimensionStyle);
                dim22.UserText = "BD_2 = " + Math.Round(bd2 / scale, 2);
                dxf.AddEntity(dim22);
                //尺寸23
                LinearDimension dim23 = new LinearDimension(new Line(v41, v38), -(v41.Y - v40.Y) / 2, 0, dimensionStyle);
                dim23.UserText = "BD_1 = " + Math.Round(bd1 / scale, 2);
                dxf.AddEntity(dim23);
                //尺寸24
                RadialDimension dimrad24 = new RadialDimension(Arc2, 135, 0, dimensionStyle);//DimensionStyle.Default);
                dimrad24.UserText = "RCF = " + Math.Round(rcf / scale, 2);
                dxf.AddEntity(dimrad24);
            }
            if (nos == 3)
            {
                //坐标
                Vector2 v1 = new Vector2(dconms / 2 - 0.5, 0);
                Vector2 v2 = new Vector2(dconms / 2, -0.5);
                Vector2 v3 = new Vector2(v2.X, -ls);
                Vector2 v4 = new Vector2(df / 2, v3.Y);
                Vector2 v5 = new Vector2(v4.X, v4.Y - flgt);
                Vector2 v6 = new Vector2(bd3 / 2, v5.Y);
                Vector2 v7 = new Vector2(v6.X, -oal + lcf);
                Vector2 v8 = new Vector2(v7.X - rcf, v7.Y - rcf);
                Vector2 v9 = new Vector2(v8.X, -oal + pl);
                Vector2 v10 = new Vector2(v7.X, -oal + sd3 + (dc3 - bd3) / 2 * Math.Tan(sta3 / 2));
                Vector2 v11 = new Vector2(dc3 / 2, -oal + sd3);
                Vector2 v35 = new Vector2(v10.X, v11.Y);
                Vector2 v36 = new Vector2(bd2 / 2, v35.Y - (bd3 - bd2) / 2 / Math.Tan(sta3 / 2));
                Vector2 v14 = new Vector2(dc2 / 2, v11.Y - (dc3 - dc2) / 2 / Math.Tan(sta3 / 2));
                Vector2 v37 = new Vector2(v36.X, -oal + pl + sdl1 + (bd2 - bd1) / 2 * Math.Cos(sta2 / 2) / Math.Sin(sta2 / 2));
                Vector2 v15 = new Vector2(v14.X, v37.Y - v14.X + v36.X);
                Vector2 v38 = new Vector2(bd1 / 2, -oal + pl + sdl1);
                Vector2 v16 = new Vector2(dc1 / 2, v15.Y - (dc2 - dc1) / 2 / Math.Tan(sta2 / 2));
                Vector2 v39 = new Vector2(v38.X, -oal + pl);
                Vector2 v17 = new Vector2(v16.X, v39.Y);
                Vector2 v18 = new Vector2(0, -oal);
                Vector2 v19 = new Vector2(-v17.X, v17.Y);
                Vector2 v20 = new Vector2(-v16.X, v16.Y);
                Vector2 v21 = new Vector2(-v15.X, v15.Y);
                Vector2 v22 = new Vector2(-v14.X, v14.Y);
                Vector2 v25 = new Vector2(-v11.X, v11.Y);
                Vector2 v26 = new Vector2(-v10.X, v10.Y);
                Vector2 v27 = new Vector2(-v6.X, v6.Y);
                Vector2 v28 = new Vector2(-v5.X, v5.Y);
                Vector2 v29 = new Vector2(-v4.X, v4.Y);
                Vector2 v30 = new Vector2(-v3.X, v3.Y);
                Vector2 v31 = new Vector2(-v2.X, v2.Y);
                Vector2 v32 = new Vector2(-v1.X, v1.Y);
                Vector2 v40 = new Vector2(-v39.X, v39.Y);
                Vector2 v41 = new Vector2(-v38.X, v38.Y);
                Vector2 v42 = new Vector2(-v37.X, v37.Y);
                Vector2 v43 = new Vector2(-v36.X, v36.Y);
                Vector2 v46 = new Vector2(-v35.X, v35.Y);
                Vector2 v47 = new Vector2(0, 2);
                Vector2 v48 = new Vector2(0, -oal - 2);
                Vector2 v49 = new Vector2(v19.X, 2 * v18.Y - v19.Y);
                Vector2 v50 = new Vector2(v17.X, 2 * v18.Y - v17.Y);
                double x51 = bd3 / 2 - rcf;
                if (v46.Y > v8.Y)
                {
                    x51 = v6.X - Math.Sqrt(rcf * rcf - (v46.Y - v8.Y) * (v46.Y - v8.Y));
                }
                double x54 = bd3 / 2 - rcf;
                if (v43.Y > v8.Y)
                {
                    x54 = v6.X - Math.Sqrt(rcf * rcf - (v43.Y - v8.Y) * (v43.Y - v8.Y));
                }
                double x55 = bd3 / 2 - rcf;
                if (v41.Y > v8.Y)
                {
                    x55 = v6.X - Math.Sqrt(rcf * rcf - (v41.Y - v8.Y) * (v41.Y - v8.Y));
                }
                double x56 = bd3 / 2 - rcf;
                if (v42.Y > v8.Y)
                {
                    x56 = v6.X - Math.Sqrt(rcf * rcf - (v42.Y - v8.Y) * (v42.Y - v8.Y));
                }
                Vector2 v51 = new Vector2(x51, v46.Y);
                Vector2 v54 = new Vector2(x54, v43.Y);
                Vector2 v55 = new Vector2(x55, v41.Y);
                Vector2 v56 = new Vector2(x56, v42.Y);
                //线段
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                Vector2[] Line3 = { v3, v4 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v4, v5 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v5, v6 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v6, v35 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                Vector2[] Line9 = { v35, v36 };
                fun.drawBLine(dxf, Line9, 0.3, contour);
                Vector2[] Line10 = { v36, v37 };
                fun.drawBLine(dxf, Line10, 0.3, contour);
                Vector2[] Line11 = { v37, v38 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
                Vector2[] Line12 = { v38, v39 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line13 = { v10, v11 };
                fun.drawPlinetype(dxf, Line13, 0.15, refin, Linetype.Dashed);
                Vector2[] Line16 = { v11, v14 };
                fun.drawPlinetype(dxf, Line16, 0.15, refin, Linetype.Dashed);
                Vector2[] Line17 = { v14, v15 };
                fun.drawPlinetype(dxf, Line17, 0.15, refin, Linetype.Dashed);
                Vector2[] Line18 = { v15, v16 };
                fun.drawPlinetype(dxf, Line18, 0.15, refin, Linetype.Dashed);
                Vector2[] Line19 = { v16, v17 };
                fun.drawPlinetype(dxf, Line19, 0.15, refin, Linetype.Dashed);
                Vector2[] Line20 = { v17, v39 };
                fun.drawPlinetype(dxf, Line20, 0.15, refin, Linetype.Dashed);
                Vector2[] Line21 = { v39, v40 };
                fun.drawBLine(dxf, Line21, 0.3, contour);
                Vector2[] Line22 = { v17, v18 };
                fun.drawPlinetype(dxf, Line22, 0.15, refin, Linetype.Dashed);
                Vector2[] Line23 = { v18, v19 };
                fun.drawPlinetype(dxf, Line23, 0.15, refin, Linetype.Dashed);
                Vector2[] Line24 = { v19, v40 };
                fun.drawPlinetype(dxf, Line24, 0.15, refin, Linetype.Dashed);
                Vector2[] Line25 = { v19, v20 };
                fun.drawPlinetype(dxf, Line25, 0.15, refin, Linetype.Dashed);
                Vector2[] Line26 = { v20, v21 };
                fun.drawPlinetype(dxf, Line26, 0.15, refin, Linetype.Dashed);
                Vector2[] Line27 = { v21, v22 };
                fun.drawPlinetype(dxf, Line27, 0.15, refin, Linetype.Dashed);
                Vector2[] Line28 = { v22, v25 };
                fun.drawPlinetype(dxf, Line28, 0.15, refin, Linetype.Dashed);
                Vector2[] Line31 = { v25, v26 };
                fun.drawPlinetype(dxf, Line31, 0.15, refin, Linetype.Dashed);
                Vector2[] Line32 = { v27, v46 };
                fun.drawBLine(dxf, Line32, 0.3, contour);
                Vector2[] Line33 = { v46, v43 };
                fun.drawBLine(dxf, Line33, 0.3, contour);
                Vector2[] Line36 = { v43, v42 };
                fun.drawBLine(dxf, Line36, 0.3, contour);
                Vector2[] Line37 = { v42, v41 };
                fun.drawBLine(dxf, Line37, 0.3, contour);
                Vector2[] Line38 = { v41, v40 };
                fun.drawBLine(dxf, Line38, 0.3, contour);
                Vector2[] Line39 = { v27, v28 };
                fun.drawBLine(dxf, Line39, 0.3, contour);
                Vector2[] Line40 = { v28, v29 };
                fun.drawBLine(dxf, Line40, 0.3, contour);
                Vector2[] Line41 = { v29, v30 };
                fun.drawBLine(dxf, Line41, 0.3, contour);
                Vector2[] Line42 = { v30, v31 };
                fun.drawBLine(dxf, Line42, 0.3, contour);
                Vector2[] Line43 = { v31, v32 };
                fun.drawBLine(dxf, Line43, 0.3, contour);
                Vector2[] Line44 = { v32, v1 };
                fun.drawBLine(dxf, Line44, 0.3, contour);
                Vector2[] Line45 = { v31, v2 };
                fun.drawBLine(dxf, Line45, 0.3, contour);
                Vector2[] Line46 = { v30, v3 };
                fun.drawBLine(dxf, Line46, 0.3, contour);
                Vector2[] Line47 = { v27, v6 };
                fun.drawBLine(dxf, Line47, 0.3, contour);
                Vector2[] Line48 = { v46, v51 };
                fun.drawBLine(dxf, Line48, 0.3, contour);
                Vector2[] Line51 = { v43, v54 };
                fun.drawBLine(dxf, Line51, 0.3, contour);
                Vector2[] Line52 = { v41, v55 };
                fun.drawBLine(dxf, Line52, 0.3, contour);
                Vector2[] Line53 = { v47, v48 };
                fun.drawPlinetype(dxf, Line53, 0.15, center, Linetype.Center);
                Line Line54 = new Line(v18, v49);
                Line Line55 = new Line(v18, v50);
                Vector2[] Line56 = { v8, v9 };
                fun.drawBLine(dxf, Line56, 0.3, contour);
                Vector2[] Line57 = { v42, v56 };
                fun.drawBLine(dxf, Line57, 0.3, contour);
                LwPolyline Arc1 = new LwPolyline();
                Arc1.Vertexes.Add(new LwPolylineVertex(v7));
                Arc1.Vertexes.Add(new LwPolylineVertex(v8));
                Arc1.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * 2 * Math.Cos(pi / 4);
                fun.PolyFill(dxf, Arc1, 0.3, contour);
                Arc Arc2 = new Arc(new Vector2(v7.X, v8.Y), rcf, 90, 180);
                //主视图图层
                Line54.Layer = dimensioning;
                Line55.Layer = dimensioning;
                //主视图
                dxf.AddEntity(Line54);
                dxf.AddEntity(Line55);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 1.0;
                double offset = 10;
                //线段尺寸标注
                //尺寸1
                Angular2LineDimension angdim1 = new Angular2LineDimension(Line54, Line55, offset / 2, dimensionStyle);
                angdim1.UserText = "SIG = " + Math.Round(sig / (pi / 180), 2) + "°";
                dxf.AddEntity(angdim1);
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(v17, v19), -pl - offset - 5, 0, dimensionStyle);
                dim2.UserText = "DC_1 = " + Math.Round(dc1 / scale, 2);
                dxf.AddEntity(dim2);
                //尺寸3
                LinearDimension dim3 = new LinearDimension(new Line(v15, v21), -v15.Y + v18.Y - offset * 2, 0, dimensionStyle);
                dim3.UserText = "DC_2 = " + Math.Round(dc2 / scale, 2);
                dxf.AddEntity(dim3);
                //尺寸4
                LinearDimension dim4 = new LinearDimension(new Line(v11, v25), -v11.Y + v18.Y - offset * 3 + 5, 0, dimensionStyle);
                dim4.UserText = "DC_3 = " + Math.Round(dc3 / scale, 2);
                dxf.AddEntity(dim4);
                //尺寸5
                LinearDimension dim5 = new LinearDimension(new Line(v18, v19), -offset - v4.X + v17.X / 2, 270, dimensionStyle);
                dim5.UserText = "PL = " + Math.Round(pl / scale, 2);
                dxf.AddEntity(dim5);
                //尺寸6
                LinearDimension dim6 = new LinearDimension(new Line(v1, v3), offset + 0.25 + v4.X - v3.X, 270, dimensionStyle);
                dim6.UserText = "LS = " + Math.Round(ls / scale, 2);
                dxf.AddEntity(dim6);
                //尺寸7
                LinearDimension dim7 = new LinearDimension(new Line(v41, v19), -offset - (v4.X - (v38.X + v17.X) / 2), 270, dimensionStyle);
                dim7.UserText = "SDL_1 = " + Math.Round(sdl1 / scale, 2);
                dxf.AddEntity(dim7);
                //尺寸8
                LinearDimension dim8 = new LinearDimension(new Line(v35, v18), offset + v4.X - v35.X / 2, 270, dimensionStyle);
                dim8.UserText = "SD_3 = " + Math.Round(sd3 / scale, 2);
                dxf.AddEntity(dim8);
                //尺寸9
                LinearDimension dim9 = new LinearDimension(new Line(v18, v1), offset * 4 + v4.X - v1.X / 2 + 0.25, 270, dimensionStyle);
                dim9.UserText = "OAL = " + Math.Round(oal / scale, 2);
                dxf.AddEntity(dim9);
                //尺寸10
                LinearDimension dim10 = new LinearDimension(new Line(v31, v2), offset + 0.5, 0, dimensionStyle);
                dim10.UserText = "DCONMS = " + Math.Round(dconms / scale, 2);
                dxf.AddEntity(dim10);
                //尺寸11
                if (sta2 != pi)
                {
                    Angular2LineDimension angdim11 = new Angular2LineDimension(new Line(v41, v42), new Line(v38, v37), v38.X / Math.Sin(sta2 / 2) * Math.Cos(sta2 / 2) + offset, dimensionStyle);
                    angdim11.UserText = "STA_2 = " + Math.Round(sta2 / (pi / 180), 2) + "°";
                    dxf.AddEntity(angdim11);
                }
                if (sta2 == pi)
                {
                    Angular2LineDimension angdim11 = new Angular2LineDimension(new Line(v41, new Vector2(v42.X, v42.Y + 0.1)), new Line(v38, new Vector2(v37.X, v37.Y + 0.1)), v38.X / Math.Sin(sta2 / 2) * Math.Cos(sta2 / 2) + offset, dimensionStyle);
                    angdim11.UserText = "STA_2 = " + Math.Round(sta2 / (pi / 180), 2) + "°";
                    dxf.AddEntity(angdim11);
                }
                //尺寸12
                Angular2LineDimension angdim12 = new Angular2LineDimension(new Line(v43, v46), new Line(v36, v35), v36.X / Math.Sin(sta3 / 2) * Math.Cos(sta3 / 2) + offset, dimensionStyle);
                angdim12.UserText = "STA_3 = " + Math.Round(sta3 / (pi / 180), 2) + "°";
                dxf.AddEntity(angdim12);
                //尺寸16
                LinearDimension dim16 = new LinearDimension(new Line(v4, v5), offset, 270, dimensionStyle);
                dim16.UserText = "FLGT = " + Math.Round(flgt / scale, 2);
                dxf.AddEntity(dim16);
                //尺寸17
                LinearDimension dim17 = new LinearDimension(new Line(v7, v18), offset * 2 - v7.X / 2 + v4.X, 270, dimensionStyle);
                dim17.UserText = "LCF = " + Math.Round(lcf / scale, 2);
                dxf.AddEntity(dim17);
                //尺寸18
                LinearDimension dim18 = new LinearDimension(new Line(v4, v18), offset * 3 + v4.X / 2, 270, dimensionStyle);
                dim18.UserText = "LPR = " + Math.Round(lpr / scale, 2);
                dxf.AddEntity(dim18);
                //尺寸19
                LinearDimension dim19 = new LinearDimension(new Line(v29, v4), -flgt / 2, 0, dimensionStyle);
                dim19.UserText = "DF = " + Math.Round(df / scale, 2);
                dxf.AddEntity(dim19);
                //尺寸20
                LinearDimension dim20 = new LinearDimension(new Line(v27, v6), -(v27.Y - v46.Y) / 2, 0, dimensionStyle);
                dim20.UserText = "BD_3 = " + Math.Round(bd3 / scale, 2);
                dxf.AddEntity(dim20);
                //尺寸22
                LinearDimension dim22 = new LinearDimension(new Line(v43, v36), -(v43.Y - v42.Y) / 2, 0, dimensionStyle);
                dim22.UserText = "BD_2 = " + Math.Round(bd2 / scale, 2);
                dxf.AddEntity(dim22);
                //尺寸23
                LinearDimension dim23 = new LinearDimension(new Line(v41, v38), -(v41.Y - v40.Y) / 2, 0, dimensionStyle);
                dim23.UserText = "BD_1 = " + Math.Round(bd1 / scale, 2);
                dxf.AddEntity(dim23);
                //尺寸24
                RadialDimension dimrad24 = new RadialDimension(Arc2, 135, 0, dimensionStyle);//DimensionStyle.Default);
                dimrad24.UserText = "RCF = " + Math.Round(rcf / scale, 2);
                dxf.AddEntity(dimrad24);
            }
            if (nos == 2)
            {
                //坐标
                Vector2 v1 = new Vector2(dconms / 2 - 0.5, 0);
                Vector2 v2 = new Vector2(dconms / 2, -0.5);
                Vector2 v3 = new Vector2(v2.X, -ls);
                Vector2 v4 = new Vector2(df / 2, v3.Y);
                Vector2 v5 = new Vector2(v4.X, v4.Y - flgt);
                Vector2 v6 = new Vector2(bd2 / 2, v5.Y);
                Vector2 v7 = new Vector2(v6.X, -oal + lcf);
                Vector2 v8 = new Vector2(v7.X - rcf, v7.Y - rcf);
                Vector2 v9 = new Vector2(v8.X, -oal + pl);
                Vector2 v10 = new Vector2(v7.X, -oal + pl + sdl1 + (dc2 - bd2) / 2 * Math.Tan(sta2 / 2) + (bd2 - bd1) / 2 / Math.Tan(sta2 / 2));
                Vector2 v11 = new Vector2(dc2 / 2, v10.Y- (dc2 - bd2) / 2 * Math.Tan(sta2 / 2));
                Vector2 v37 = new Vector2(v10.X, v11.Y);
                Vector2 v38 = new Vector2(bd1 / 2, -oal + pl + sdl1);
                Vector2 v16 = new Vector2(dc1 / 2, v11.Y - (dc2 - dc1) / 2 / Math.Tan(sta2 / 2));
                Vector2 v39 = new Vector2(v38.X, -oal + pl);
                Vector2 v17 = new Vector2(v16.X, v39.Y);
                Vector2 v18 = new Vector2(0, -oal);
                Vector2 v19 = new Vector2(-v17.X, v17.Y);
                Vector2 v20 = new Vector2(-v16.X, v16.Y);
                Vector2 v25 = new Vector2(-v11.X, v11.Y);
                Vector2 v26 = new Vector2(-v10.X, v10.Y);
                Vector2 v27 = new Vector2(-v6.X, v6.Y);
                Vector2 v28 = new Vector2(-v5.X, v5.Y);
                Vector2 v29 = new Vector2(-v4.X, v4.Y);
                Vector2 v30 = new Vector2(-v3.X, v3.Y);
                Vector2 v31 = new Vector2(-v2.X, v2.Y);
                Vector2 v32 = new Vector2(-v1.X, v1.Y);
                Vector2 v40 = new Vector2(-v39.X, v39.Y);
                Vector2 v41 = new Vector2(-v38.X, v38.Y);
                Vector2 v42 = new Vector2(-v37.X, v37.Y);
                Vector2 v47 = new Vector2(0, 2);
                Vector2 v48 = new Vector2(0, -oal - 2);
                Vector2 v49 = new Vector2(v19.X, 2 * v18.Y - v19.Y);
                Vector2 v50 = new Vector2(v17.X, 2 * v18.Y - v17.Y);
                double x55 = bd2 / 2 - rcf;
                if (v41.Y > v8.Y)
                {
                    x55 = v6.X - Math.Sqrt(rcf * rcf - (v41.Y - v8.Y) * (v41.Y - v8.Y));
                }
                double x56 = bd2 / 2 - rcf;
                if (v42.Y > v8.Y)
                {
                    x56 = v6.X - Math.Sqrt(rcf * rcf - (v42.Y - v8.Y) * (v42.Y - v8.Y));
                }
                Vector2 v55 = new Vector2(x55, v41.Y);
                Vector2 v56 = new Vector2(x56, v42.Y);
                //线段
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                Vector2[] Line3 = { v3, v4 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v4, v5 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v5, v6 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v6, v37 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                Vector2[] Line11 = { v37, v38 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
                Vector2[] Line12 = { v38, v39 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line13 = { v10, v11 };
                fun.drawPlinetype(dxf, Line13, 0.15, refin, Linetype.Dashed);
                Vector2[] Line18 = { v11, v16 };
                fun.drawPlinetype(dxf, Line18, 0.15, refin, Linetype.Dashed);
                Vector2[] Line19 = { v16, v17 };
                fun.drawPlinetype(dxf, Line19, 0.15, refin, Linetype.Dashed);
                Vector2[] Line20 = { v17, v39 };
                fun.drawPlinetype(dxf, Line20, 0.15, refin, Linetype.Dashed);
                Vector2[] Line21 = { v39, v40 };
                fun.drawBLine(dxf, Line21, 0.3, contour);
                Vector2[] Line22 = { v17, v18 };
                fun.drawPlinetype(dxf, Line22, 0.15, refin, Linetype.Dashed);
                Vector2[] Line23 = { v18, v19 };
                fun.drawPlinetype(dxf, Line23, 0.15, refin, Linetype.Dashed);
                Vector2[] Line24 = { v19, v40 };
                fun.drawPlinetype(dxf, Line24, 0.15, refin, Linetype.Dashed);
                Vector2[] Line25 = { v19, v20 };
                fun.drawPlinetype(dxf, Line25, 0.15, refin, Linetype.Dashed);
                Vector2[] Line26 = { v20, v25 };
                fun.drawPlinetype(dxf, Line26, 0.15, refin, Linetype.Dashed);
                Vector2[] Line31 = { v25, v26 };
                fun.drawPlinetype(dxf, Line31, 0.15, refin, Linetype.Dashed);
                Vector2[] Line32 = { v27, v42 };
                fun.drawBLine(dxf, Line32, 0.3, contour);
                Vector2[] Line37 = { v42, v41 };
                fun.drawBLine(dxf, Line37, 0.3, contour);
                Vector2[] Line38 = { v41, v40 };
                fun.drawBLine(dxf, Line38, 0.3, contour);
                Vector2[] Line39 = { v27, v28 };
                fun.drawBLine(dxf, Line39, 0.3, contour);
                Vector2[] Line40 = { v28, v29 };
                fun.drawBLine(dxf, Line40, 0.3, contour);
                Vector2[] Line41 = { v29, v30 };
                fun.drawBLine(dxf, Line41, 0.3, contour);
                Vector2[] Line42 = { v30, v31 };
                fun.drawBLine(dxf, Line42, 0.3, contour);
                Vector2[] Line43 = { v31, v32 };
                fun.drawBLine(dxf, Line43, 0.3, contour);
                Vector2[] Line44 = { v32, v1 };
                fun.drawBLine(dxf, Line44, 0.3, contour);
                Vector2[] Line45 = { v31, v2 };
                fun.drawBLine(dxf, Line45, 0.3, contour);
                Vector2[] Line46 = { v30, v3 };
                fun.drawBLine(dxf, Line46, 0.3, contour);
                Vector2[] Line47 = { v27, v6 };
                fun.drawBLine(dxf, Line47, 0.3, contour);
                Vector2[] Line48 = { v42, v56 };
                fun.drawBLine(dxf, Line48, 0.3, contour);
                Vector2[] Line51 = { v41, v55 };
                fun.drawBLine(dxf, Line51, 0.3, contour);
                Vector2[] Line53 = { v47, v48 };
                fun.drawPlinetype(dxf, Line53, 0.15, center, Linetype.Center);
                Line Line54 = new Line(v18, v49);
                Line Line55 = new Line(v18, v50);
                Vector2[] Line56 = { v8, v9 };
                fun.drawBLine(dxf, Line56, 0.3, contour);
                LwPolyline Arc1 = new LwPolyline();
                Arc1.Vertexes.Add(new LwPolylineVertex(v7));
                Arc1.Vertexes.Add(new LwPolylineVertex(v8));
                Arc1.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * 2 * Math.Cos(pi / 4);
                fun.PolyFill(dxf, Arc1, 0.3, contour);
                Arc Arc2 = new Arc(new Vector2(v7.X, v8.Y), rcf, 90, 180);
                //主视图图层
                Line54.Layer = dimensioning;
                Line55.Layer = dimensioning;
                //主视图
                dxf.AddEntity(Line54);
                dxf.AddEntity(Line55);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 1.0;
                double offset = 10;
                //线段尺寸标注
                //尺寸1
                Angular2LineDimension angdim1 = new Angular2LineDimension(Line54, Line55, offset / 2, dimensionStyle);
                angdim1.UserText = "SIG = " + Math.Round(sig / (pi / 180), 2) + "°";
                dxf.AddEntity(angdim1);
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(v17, v19), -pl - offset - 5, 0, dimensionStyle);
                dim2.UserText = "DC_1 = " + Math.Round(dc1 / scale, 2);
                dxf.AddEntity(dim2);
                //尺寸3
                LinearDimension dim3 = new LinearDimension(new Line(v11, v25), -v11.Y + v18.Y - offset * 2, 0, dimensionStyle);
                dim3.UserText = "DC_2 = " + Math.Round(dc2 / scale, 2);
                dxf.AddEntity(dim3);
                //尺寸5
                LinearDimension dim5 = new LinearDimension(new Line(v18, v19), -offset - v4.X + v17.X / 2, 270, dimensionStyle);
                dim5.UserText = "PL = " + Math.Round(pl / scale, 2);
                dxf.AddEntity(dim5);
                //尺寸6
                LinearDimension dim6 = new LinearDimension(new Line(v1, v3), offset + 0.25 + v4.X - v3.X, 270, dimensionStyle);
                dim6.UserText = "LS = " + Math.Round(ls / scale, 2);
                dxf.AddEntity(dim6);
                //尺寸7
                LinearDimension dim7 = new LinearDimension(new Line(v41, v19), -offset - (v4.X - (v38.X + v17.X) / 2), 270, dimensionStyle);
                dim7.UserText = "SDL_1 = " + Math.Round(sdl1 / scale, 2);
                dxf.AddEntity(dim7);
                //尺寸9
                LinearDimension dim9 = new LinearDimension(new Line(v18, v1), offset * 3 + v4.X - v1.X / 2 + 0.25, 270, dimensionStyle);
                dim9.UserText = "OAL = " + Math.Round(oal / scale, 2);
                dxf.AddEntity(dim9);
                //尺寸10
                LinearDimension dim10 = new LinearDimension(new Line(v31, v2), offset + 0.5, 0, dimensionStyle);
                dim10.UserText = "DCONMS = " + Math.Round(dconms / scale, 2);
                dxf.AddEntity(dim10);
                //尺寸11
                Angular2LineDimension angdim11 = new Angular2LineDimension(new Line(v41, v42), new Line(v38, v37), v38.X / Math.Sin(sta2 / 2) * Math.Cos(sta2 / 2) + offset, dimensionStyle);
                angdim11.UserText = "STA_2 = " + Math.Round(sta2 / (pi / 180), 2) + "°";
                dxf.AddEntity(angdim11);
                //尺寸16
                LinearDimension dim16 = new LinearDimension(new Line(v4, v5), offset, 270, dimensionStyle);
                dim16.UserText = "FLGT = " + Math.Round(flgt / scale, 2);
                dxf.AddEntity(dim16);
                //尺寸17
                LinearDimension dim17 = new LinearDimension(new Line(v7, v18), offset - v7.X / 2 + v4.X, 270, dimensionStyle);
                dim17.UserText = "LCF = " + Math.Round(lcf / scale, 2);
                dxf.AddEntity(dim17);
                //尺寸18
                LinearDimension dim18 = new LinearDimension(new Line(v4, v18), offset * 2 + v4.X / 2, 270, dimensionStyle);
                dim18.UserText = "LPR = " + Math.Round(lpr / scale, 2);
                dxf.AddEntity(dim18);
                //尺寸19
                LinearDimension dim19 = new LinearDimension(new Line(v29, v4), -flgt / 2, 0, dimensionStyle);
                dim19.UserText = "DF = " + Math.Round(df / scale, 2);
                dxf.AddEntity(dim19);
                //尺寸20
                LinearDimension dim20 = new LinearDimension(new Line(v27, v6), -(v27.Y - v42.Y) / 2, 0, dimensionStyle);
                dim20.UserText = "BD_2 = " + Math.Round(bd2 / scale, 2);
                dxf.AddEntity(dim20);
                //尺寸23
                LinearDimension dim23 = new LinearDimension(new Line(v41, v38), -(v41.Y - v40.Y) / 2, 0, dimensionStyle);
                dim23.UserText = "BD_1 = " + Math.Round(bd1 / scale, 2);
                dxf.AddEntity(dim23);
                //尺寸24
                RadialDimension dimrad24 = new RadialDimension(Arc2, 135, 0, dimensionStyle);//DimensionStyle.Default);
                dimrad24.UserText = "RCF = " + Math.Round(rcf / scale, 2);
                dxf.AddEntity(dimrad24);
            }
            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(-148.5, 200 - oal / 2));
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            //定义格式，根据路径导出

            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
        public static void CoreDrillForIndexableInsert(Dictionary<string, Object> data) //可转位扩孔钻
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);
            //作图
            //参数
            string path = Convert.ToString(data["path"]);
            double soal = Convert.ToDouble(data["oal"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0 && soal < 67)
            {
                scale = 4.0;
            }
            else if (scale == 0 && soal < 90)
            {
                scale = 3.0;
            }
            else if (scale == 0 && soal < 134)
            {
                scale = 2.0;
            }
            else if (scale == 0 && soal < 178)
            {
                scale = 1.5;
            }
            else if (scale == 0 && soal < 268)
            {
                scale = 1.0;
            }
            else if (scale == 0 && soal < 357)
            {
                scale = 0.75;
            }
            else if (scale == 0)
            {
                scale = 0.5;
            }
            double pi = Math.PI;
            double bd = Convert.ToDouble(data["bd"]) * scale;
            double dc = Convert.ToDouble(data["dc"]) * scale;
            double dconms = Convert.ToDouble(data["dconms"]) * scale;
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double ls = Convert.ToDouble(data["ls"]) * scale;
            double df = Convert.ToDouble(data["df"]) * scale;
            double flgt = Convert.ToDouble(data["flgt"]) * scale;
            double lcf = Convert.ToDouble(data["lcf"]) * scale;
            double rcf = Convert.ToDouble(data["rcf"]) * scale;
            double sig = Convert.ToDouble(data["sig"]) * pi / 180;
            double isframe = Convert.ToDouble(data["isframe"]);
            double pl = dc / 2 / Math.Tan(sig / 2);
            double lu = lcf - rcf;
            double lpr = oal - ls;
            double lf = lpr - pl;
            //坐标
            //主视图
            Vector2 v1 = new Vector2(dconms / 2 - 0.5, 0);
            Vector2 v2 = new Vector2(v1.X + 0.5, -0.5);
            Vector2 v3 = new Vector2(v2.X, -ls);
            Vector2 v4 = new Vector2(df / 2, v3.Y);
            Vector2 v5 = new Vector2(v4.X, v4.Y - flgt);
            Vector2 v6 = new Vector2(bd / 2, v5.Y);
            Vector2 v7 = new Vector2(v6.X, -oal + lcf);
            Vector2 v8 = new Vector2(v7.X - rcf, v7.Y - rcf);
            Vector2 v9 = new Vector2(v8.X, -oal + pl);
            Vector2 v10 = new Vector2(v7.X, v9.Y);
            Vector2 v11 = new Vector2(dc / 2, v10.Y);
            Vector2 v12 = new Vector2(0, -oal);
            Vector2 v13 = new Vector2(-v11.X, v11.Y);
            Vector2 v14 = new Vector2(-v10.X, v10.Y);
            Vector2 v15 = new Vector2(-v9.X, v9.Y);
            Vector2 v16 = new Vector2(-v8.X, v8.Y);
            Vector2 v17 = new Vector2(-v7.X, v7.Y);
            Vector2 v18 = new Vector2(-v6.X, v6.Y);
            Vector2 v19 = new Vector2(-v5.X, v5.Y);
            Vector2 v20 = new Vector2(-v4.X, v4.Y);
            Vector2 v21 = new Vector2(-v3.X, v3.Y);
            Vector2 v22 = new Vector2(-v2.X, v2.Y);
            Vector2 v23 = new Vector2(-v1.X, v1.Y);
            Vector2 v24 = new Vector2(0, 2);
            Vector2 v25 = new Vector2(0, -oal - 2);
            Vector2 v26 = new Vector2(v13.X, v12.Y * 2 - v13.Y);
            Vector2 v27 = new Vector2(v11.X, v12.Y * 2 - v11.Y);
            //线段
            //主视图
            Vector2[] Line1 = { v1, v2 };
            fun.drawBLine(dxf, Line1, 0.3, contour);
            Vector2[] Line2 = { v2, v3 };
            fun.drawBLine(dxf, Line2, 0.3, contour);
            Vector2[] Line3 = { v3, v4 };
            fun.drawBLine(dxf, Line3, 0.3, contour);
            Vector2[] Line4 = { v4, v5 };
            fun.drawBLine(dxf, Line4, 0.3, contour);
            Vector2[] Line5 = { v5, v6 };
            fun.drawBLine(dxf, Line5, 0.3, contour);
            Vector2[] Line6 = { v6, v10 };
            fun.drawBLine(dxf, Line6, 0.3, contour);
            LwPolyline Arc7 = new LwPolyline();
            Arc7.Vertexes.Add(new LwPolylineVertex(v7));
            Arc7.Vertexes.Add(new LwPolylineVertex(v8));
            Arc7.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * Math.Cos(pi / 4) * 2;
            fun.PolyFill(dxf, Arc7, 0.5, contour);
            Vector2[] Line8 = { v8, v9 };
            fun.drawBLine(dxf, Line8, 0.5, contour);
            Vector2[] Line9 = { v10, v14 };
            fun.drawBLine(dxf, Line9, 0.3, contour);
            Vector2[] Line10 = { v10, v11 };
            fun.drawPlinetype(dxf, Line10, 0.15, refin, Linetype.Dashed);
            Vector2[] Line11 = { v11, v12 };
            fun.drawPlinetype(dxf, Line11, 0.15, refin, Linetype.Dashed);
            Vector2[] Line12 = { v12, v13 };
            fun.drawPlinetype(dxf, Line12, 0.15, refin, Linetype.Dashed);
            Vector2[] Line13 = { v13, v14 };
            fun.drawPlinetype(dxf, Line13, 0.15, refin, Linetype.Dashed);
            Vector2[] Line14 = { v14, v17 };
            fun.drawBLine(dxf, Line14, 0.3, contour);
            Vector2[] Line15 = { v15, v16 };
            fun.drawPlinetype(dxf, Line15, 0.15, refin, Linetype.Dashed);
            /*LwPolyline Arc16 = new LwPolyline();
            Arc16.Vertexes.Add(new LwPolylineVertex(v16));
            Arc16.Vertexes.Add(new LwPolylineVertex(v17));
            Arc16.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * Math.Cos(pi / 4) * 2;
            fun.PolyFillandlinetype(dxf, Arc16, 0, refin, Linetype.Center);*/
            Vector2[] Line17 = { v17, v18 };
            fun.drawBLine(dxf, Line17, 0.3, contour);
            Vector2[] Line18 = { v18, v19 };
            fun.drawBLine(dxf, Line18, 0.3, contour);
            Vector2[] Line19 = { v19, v20 };
            fun.drawBLine(dxf, Line19, 0.3, contour);
            Vector2[] Line20 = { v20, v21 };
            fun.drawBLine(dxf, Line20, 0.3, contour);
            Vector2[] Line21 = { v21, v22 };
            fun.drawBLine(dxf, Line21, 0.3, contour);
            Vector2[] Line22 = { v22, v23 };
            fun.drawBLine(dxf, Line22, 0.3, contour);
            Vector2[] Line23 = { v23, v1 };
            fun.drawBLine(dxf, Line23, 0.3, contour);
            Vector2[] Line24 = { v22, v2 };
            fun.drawBLine(dxf, Line24, 0.3, contour);
            Vector2[] Line25 = { v21, v3 };
            fun.drawBLine(dxf, Line25, 0.3, contour);
            Vector2[] Line26 = { v18, v6 };
            fun.drawBLine(dxf, Line26, 0.3, contour);
            Vector2[] Line27 = { v24, v25 };
            fun.drawPlinetype(dxf, Line27, 0.15, center, Linetype.Center);
            Arc arc28 = new Arc(new Vector2(v7.X, v8.Y), rcf, 90, 180);
            Line Line29 = new Line(v12, v26);
            Line Line30 = new Line(v12, v27);
            Arc arc31 = new Arc(new Vector2(v17.X, v16.Y), rcf, 0, 90);
            Line29.Layer = dimensioning;
            Line30.Layer = dimensioning;
            arc31.Layer = refin;
            arc31.Linetype = Linetype.Dashed;
            dxf.AddEntity(Line29);
            dxf.AddEntity(Line30);
            dxf.AddEntity(arc31);
            //标注样式
            //箭头样式
            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 0.2;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            //文本样式
            dimensionStyle.TextHeight = 1.0;
            double offset = 10;
            //线段尺寸标注
            //尺寸1
            LinearDimension dim1 = new LinearDimension(new Line(v19, v20), -offset, 270, dimensionStyle);
            dim1.UserText = "FLGT = " + Math.Round(flgt / scale, 2);
            dxf.AddEntity(dim1);
            //尺寸2
            LinearDimension dim2 = new LinearDimension(new Line(v11, v13), -offset * 3 - pl-20, 0, dimensionStyle);
            dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
            dxf.AddEntity(dim2);
            //尺寸3
            LinearDimension dim3 = new LinearDimension(new Line(v20, v13), -offset * 2 - (v13.X - v20.X) / 2, 270, dimensionStyle);
            dim3.UserText = "LF = " + Math.Round(lf / scale, 2);
            dxf.AddEntity(dim3);
            //尺寸4
            LinearDimension dim4 = new LinearDimension(new Line(v20, v23), -offset * 3 - (v23.X - v20.X) / 2, 270, dimensionStyle);
            dim4.UserText = "LS = " + Math.Round(ls / scale, 2);
            dxf.AddEntity(dim4);
            //尺寸5
            LinearDimension dim5 = new LinearDimension(new Line(v12, v1), offset * 3 + v4.X - v1.X / 2, 270, dimensionStyle);
            dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
            dxf.AddEntity(dim5);
            //尺寸6
            LinearDimension dim6 = new LinearDimension(new Line(v22, v2), offset + 0.5, 0, dimensionStyle);
            dim6.UserText = "DCONMS = " + Math.Round(dconms / scale, 2);
            dxf.AddEntity(dim6);
            //尺寸7
            LinearDimension dim7 = new LinearDimension(new Line(v20, v4), offset * 2 + v1.Y - v4.Y, 0, dimensionStyle);
            dim7.UserText = "DF = " + Math.Round(df / scale, 2);
            dxf.AddEntity(dim7);
            //尺寸8
            LinearDimension dim8 = new LinearDimension(new Line(v10, v14), -offset * 3 - pl-10, 0, dimensionStyle);
            dim8.UserText = "BD = " + Math.Round(bd / scale, 2);

            dxf.AddEntity(dim8);
            //尺寸9
            LinearDimension dim9 = new LinearDimension(new Line(v12, v20), -offset * 3 + v20.X / 2, 270, dimensionStyle);
            dim9.UserText = "LPR = " + Math.Round(lpr / scale, 2);
            dxf.AddEntity(dim9);
            //尺寸10
            LinearDimension dim10 = new LinearDimension(new Line(v12, v8), offset + v8.X / 2 + v4.X - v8.X, 270, dimensionStyle);
            dim10.UserText = "LU = " + Math.Round(lu / scale, 2);
            dxf.AddEntity(dim10);
            //尺寸11
            LinearDimension dim11 = new LinearDimension(new Line(v12, v7), offset * 2 + v7.X / 2 + v4.X - v7.X, 270, dimensionStyle);
            dim11.UserText = "LCF = " + Math.Round(lcf / scale, 2);
            dxf.AddEntity(dim11);
            //尺寸12
            LinearDimension dim12 = new LinearDimension(new Line(v12, v11), offset / 2 + v11.X / 2 + v4.X - v11.X, 270, dimensionStyle);
            dim12.UserText = "PL = " + Math.Round(pl / scale, 2);
            dxf.AddEntity(dim12);
            //尺寸13
            RadialDimension dimrad13 = new RadialDimension(arc28, 135, -rcf + 5, dimensionStyle);//DimensionStyle.Default);
            dimrad13.UserText = "RCF = " + Math.Round(rcf / scale, 2);
            dxf.AddEntity(dimrad13);
            //尺寸14
            Angular2LineDimension angdim14 = new Angular2LineDimension(Line29, Line30, offset, dimensionStyle);
            angdim14.UserText = "SIG = " + Math.Round(sig / pi * 180, 2) + "°";
            dxf.AddEntity(angdim14);
            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(-148.5, 210 - oal / 2));
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            //定义格式，根据路径导出

            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
        public static void FaceCountersinkingToolForIndexableInsert(Dictionary<string, Object> data) //可转位平面锪孔工具
        {
            DxfDocument dxf = new DxfDocument();
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);
            //作图
            //参数
            string path = Convert.ToString(data["path"]);
            double soal = Convert.ToDouble(data["oal"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0 && soal < 67)
            {
                scale = 4.0;
            }
            else if (scale == 0 && soal < 90)
            {
                scale = 3.0;
            }
            else if (scale == 0 && soal < 134)
            {
                scale = 2.0;
            }
            else if (scale == 0 && soal < 178)
            {
                scale = 1.5;
            }
            else if (scale == 0 && soal < 268)
            {
                scale = 1.0;
            }
            else if (scale == 0 && soal < 357)
            {
                scale = 0.75;
            }
            else if (scale == 0)
            {
                scale = 0.5;
            }
            double pi = Math.PI;
            double bd = Convert.ToDouble(data["bd"]) * scale;
            double dc = Convert.ToDouble(data["dc"]) * scale;
            double dconms = Convert.ToDouble(data["dconms"]) * scale;
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double ls = Convert.ToDouble(data["ls"]) * scale;
            double df = Convert.ToDouble(data["df"]) * scale;
            double flgt = Convert.ToDouble(data["flgt"]) * scale;
            double lcf = Convert.ToDouble(data["lcf"]) * scale;
            double rcf = Convert.ToDouble(data["rcf"]) * scale;
            double sig = Convert.ToDouble(data["sig"]) * pi / 180;
            double ic = Convert.ToDouble(data["ic"]) * scale;
            double isframe = Convert.ToDouble(data["isframe"]);
            double lu = lcf - rcf;
            double lpr = oal - ls;
            //坐标
            //主视图
            Vector2 v1 = new Vector2(dconms / 2 - 0.5, 0);
            Vector2 v2 = new Vector2(v1.X + 0.5, -0.5);
            Vector2 v3 = new Vector2(v2.X, -ls);
            Vector2 v4 = new Vector2(df / 2, v3.Y);
            Vector2 v5 = new Vector2(v4.X, v4.Y - flgt);
            Vector2 v6 = new Vector2(bd / 2, v5.Y);
            Vector2 v7 = new Vector2(v6.X, -oal + lcf);
            Vector2 v8 = new Vector2(v7.X - rcf, v7.Y - rcf);
            Vector2 v9 = new Vector2(v8.X, -oal + (dc-bd)/2);
            Vector2 v10 = new Vector2(v7.X, v9.Y);
            Vector2 v11 = new Vector2(dc / 2, -oal);
            Vector2 v12 = new Vector2(v11.X, -oal+ic);
            Vector2 v13 = new Vector2(v12.X-ic, v12.Y);
            Vector2 v14 = new Vector2(v13.X, v11.Y);
            Vector2 v15 = new Vector2(-v9.X, v9.Y);
            Vector2 v16 = new Vector2(-v8.X, v8.Y);
            Vector2 v17 = new Vector2(-v7.X, v7.Y);
            Vector2 v18 = new Vector2(-v6.X, v6.Y);
            Vector2 v19 = new Vector2(-v5.X, v5.Y);
            Vector2 v20 = new Vector2(-v4.X, v4.Y);
            Vector2 v21 = new Vector2(-v3.X, v3.Y);
            Vector2 v22 = new Vector2(-v2.X, v2.Y);
            Vector2 v23 = new Vector2(-v1.X, v1.Y);
            Vector2 v24 = new Vector2(-v10.X, v10.Y);
            Vector2 v25 = new Vector2(-v11.X, v11.Y);
            Vector2 v26 = new Vector2(-v12.X, v12.Y);
            Vector2 v27 = new Vector2(-v13.X, v13.Y);
            Vector2 v28 = new Vector2(-v14.X, v14.Y);
            Vector2 v29 = new Vector2(0, 2);
            Vector2 v30 = new Vector2(0, -oal - 2);
            Vector2 v31 = new Vector2(v24.X - 2, -oal - 0.01);
            Vector2 v32 = new Vector2(v10.X + 2, -oal - 0.01);
            Vector2 v33 = new Vector2(0, -oal);
            //线段
            //主视图
            Vector2[] Line1 = { v1, v2 };
            fun.drawBLine(dxf, Line1, 0.3, contour);
            Vector2[] Line2 = { v2, v3 };
            fun.drawBLine(dxf, Line2, 0.3, contour);
            Vector2[] Line3 = { v3, v4 };
            fun.drawBLine(dxf, Line3, 0.3, contour);
            Vector2[] Line4 = { v4, v5 };
            fun.drawBLine(dxf, Line4, 0.3, contour);
            Vector2[] Line5 = { v5, v6 };
            fun.drawBLine(dxf, Line5, 0.3, contour);
            Vector2[] Line6 = { v6, v10 };
            fun.drawBLine(dxf, Line6, 0.3, contour);
            LwPolyline Arc7 = new LwPolyline();
            Arc7.Vertexes.Add(new LwPolylineVertex(v7));
            Arc7.Vertexes.Add(new LwPolylineVertex(v8));
            Arc7.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * Math.Cos(pi / 4) * 2;
            fun.PolyFill(dxf, Arc7, 0.5, contour);
            Vector2[] Line8 = { v8, v9 };
            fun.drawBLine(dxf, Line8, 0.5, contour);
            Vector2[] Line9 = { v10, v24 };
            fun.drawBLine(dxf, Line9, 0.3, contour);
            Vector2[] Line10 = { v11, v12 };
            fun.drawPlinetype(dxf, Line10, 0.15, refin, Linetype.Dashed);
            Vector2[] Line11 = { v12, v13 };
            fun.drawPlinetype(dxf, Line11, 0.15, refin, Linetype.Dashed);
            Vector2[] Line12 = { v13, v14 };
            fun.drawPlinetype(dxf, Line12, 0.15, refin, Linetype.Dashed);
            Vector2[] Line13 = { v14, v11 };
            fun.drawPlinetype(dxf, Line13, 0.15, refin, Linetype.Dashed);
            Vector2[] Line14 = { v24, v18 };
            fun.drawBLine(dxf, Line14, 0.3, contour);
            Vector2[] Line15 = { v15, v16 };
            fun.drawPlinetype(dxf, Line15, 0.15, refin, Linetype.Dashed);
            /*LwPolyline Arc16 = new LwPolyline();
            Arc16.Vertexes.Add(new LwPolylineVertex(v16));
            Arc16.Vertexes.Add(new LwPolylineVertex(v17));
            Arc16.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * Math.Cos(pi / 4) * 2;
            fun.PolyFillandlinetype(dxf, Arc16, 0, refin, Linetype.Center);*/
            Vector2[] Line17 = { v6, v18 };
            fun.drawBLine(dxf, Line17, 0.3, contour);
            Vector2[] Line18 = { v18, v19 };
            fun.drawBLine(dxf, Line18, 0.3, contour);
            Vector2[] Line19 = { v19, v20 };
            fun.drawBLine(dxf, Line19, 0.3, contour);
            Vector2[] Line20 = { v20, v21 };
            fun.drawBLine(dxf, Line20, 0.3, contour);
            Vector2[] Line21 = { v21, v22 };
            fun.drawBLine(dxf, Line21, 0.3, contour);
            Vector2[] Line22 = { v22, v23 };
            fun.drawBLine(dxf, Line22, 0.3, contour);
            Vector2[] Line23 = { v23, v1 };
            fun.drawBLine(dxf, Line23, 0.3, contour);
            Vector2[] Line24 = { v22, v2 };
            fun.drawBLine(dxf, Line24, 0.3, contour);
            Vector2[] Line25 = { v21, v3 };
            fun.drawBLine(dxf, Line25, 0.3, contour);
            Vector2[] Line26 = { v25, v26 };
            fun.drawPlinetype(dxf, Line26, 0.15, refin, Linetype.Dashed);
            Vector2[] Line27 = { v26, v27 };
            fun.drawPlinetype(dxf, Line27, 0.15, refin, Linetype.Dashed);
            Vector2[] Line28 = { v27, v28 };
            fun.drawPlinetype(dxf, Line28, 0.15, refin, Linetype.Dashed);
            Vector2[] Line29 = { v28, v25 };
            fun.drawPlinetype(dxf, Line29, 0.15, refin, Linetype.Dashed);
            Vector2[] Line30 = { v29, v30 };
            fun.drawPlinetype(dxf, Line30, 0.15, center, Linetype.Center);
            Arc arc31 = new Arc(new Vector2(v7.X, v8.Y), rcf, 90, 180);
            Line Line32 = new Line(v33, v31);
            Line Line33 = new Line(v33, v32);
            Arc arc34 = new Arc(new Vector2(v17.X, v16.Y), rcf, 0, 90);
            Line32.Layer = dimensioning;
            Line33.Layer = dimensioning;
            arc34.Layer = refin;
            arc34.Linetype = Linetype.Dashed;
            dxf.AddEntity(Line32);
            dxf.AddEntity(Line33);
            dxf.AddEntity(arc34);
            //标注样式
            //箭头样式
            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 0.2;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            //文本样式
            dimensionStyle.TextHeight = 1.0;
            double offset = 10;
            //线段尺寸标注
            //尺寸1
            LinearDimension dim1 = new LinearDimension(new Line(v19, v20), -offset, 270, dimensionStyle);
            dim1.UserText = "FLGT = " + Math.Round(flgt / scale, 2);
            dxf.AddEntity(dim1);
            //尺寸2
            LinearDimension dim2 = new LinearDimension(new Line(v11, v25), -offset * 3, 0, dimensionStyle);
            dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
            dxf.AddEntity(dim2);
            //尺寸4
            LinearDimension dim4 = new LinearDimension(new Line(v20, v23), -offset * 2 - (v23.X - v20.X) / 2, 270, dimensionStyle);
            dim4.UserText = "LS = " + Math.Round(ls / scale, 2);
            dxf.AddEntity(dim4);
            //尺寸5
            LinearDimension dim5 = new LinearDimension(new Line(v11, v1), offset * 3 + v4.X - (v1.X+v11.X) / 2, 270, dimensionStyle);
            dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
            dxf.AddEntity(dim5);
            //尺寸6
            LinearDimension dim6 = new LinearDimension(new Line(v22, v2), offset + 0.5, 0, dimensionStyle);
            dim6.UserText = "DCONMS = " + Math.Round(dconms / scale, 2);
            dxf.AddEntity(dim6);
            //尺寸7
            LinearDimension dim7 = new LinearDimension(new Line(v20, v4), offset * 2 + v1.Y - v4.Y, 0, dimensionStyle);
            dim7.UserText = "DF = " + Math.Round(df / scale, 2);
            dxf.AddEntity(dim7);
            //尺寸8
            LinearDimension dim8 = new LinearDimension(new Line(v10, v24), -offset * 2 - v10.Y+v11.Y, 0, dimensionStyle);
            dim8.UserText = "BD = " + Math.Round(bd / scale, 2);
            dxf.AddEntity(dim8);
            //尺寸9
            LinearDimension dim9 = new LinearDimension(new Line(v25, v20), -offset * 2 - (v25.X-v20.X) / 2, 270, dimensionStyle);
            dim9.UserText = "LPR = " + Math.Round(lpr / scale, 2);
            dxf.AddEntity(dim9);
            //尺寸10
            LinearDimension dim10 = new LinearDimension(new Line(v11, v8), offset + v4.X -(v11.X+v8.X) / 2, 270, dimensionStyle);
            dim10.UserText = "LU = " + Math.Round(lu / scale, 2);
            dxf.AddEntity(dim10);
            //尺寸11
            LinearDimension dim11 = new LinearDimension(new Line(v11, v7), offset * 2 + v4.X - (v7.X+v11.X) / 2, 270, dimensionStyle);
            dim11.UserText = "LCF = " + Math.Round(lcf / scale, 2);
            dxf.AddEntity(dim11);
            //尺寸13
            RadialDimension dimrad13 = new RadialDimension(arc31, 135, -rcf + 5, dimensionStyle);//DimensionStyle.Default);
            dimrad13.UserText = "RCF = " + Math.Round(rcf / scale, 2);
            dxf.AddEntity(dimrad13);
            //尺寸14
            Angular2LineDimension angdim14 = new Angular2LineDimension(Line32, Line33, offset, dimensionStyle);
            angdim14.UserText = "SIG = " + Math.Round(sig / pi * 180, 2) + "°";
            dxf.AddEntity(angdim14);
            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(-148.5, 210 - oal / 2));
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            //定义格式，根据路径导出

            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
        public static void StepCountersinkingToolForIndexableInsert(Dictionary<string, Object> data)//可转位阶梯锪孔刀具
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);
            //作图
            //参数
            string path = Convert.ToString(data["path"]);
            double soal = Convert.ToDouble(data["oal"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0 && soal < 67)
            {
                scale = 4.0;
            }
            else if (scale == 0 && soal < 90)
            {
                scale = 3.0;
            }
            else if (scale == 0 && soal < 134)
            {
                scale = 2.0;
            }
            else if (scale == 0 && soal < 178)
            {
                scale = 1.5;
            }
            else if (scale == 0 && soal < 268)
            {
                scale = 1.0;
            }
            else if (scale == 0 && soal < 357)
            {
                scale = 0.75;
            }
            else if (scale == 0)
            {
                scale = 0.5;
            }
            double pi = Math.PI;
            double dc1 = Convert.ToDouble(data["dc1"]) * scale;
            double dc2 = Convert.ToDouble(data["dc2"]) * scale;
            double dc3 = Convert.ToDouble(data["dc3"]) * scale;
            double dc4 = Convert.ToDouble(data["dc4"]) * scale;
            double bd1 = Convert.ToDouble(data["bd1"]) * scale;
            double bd2 = Convert.ToDouble(data["bd2"]) * scale;
            double bd3 = Convert.ToDouble(data["bd3"]) * scale;
            double bd4 = Convert.ToDouble(data["bd4"]) * scale;
            double sdl1 = Convert.ToDouble(data["sdl1"]) * scale;
            double sd4 = Convert.ToDouble(data["sd4"]) * scale;
            double sd3 = Convert.ToDouble(data["sd3"]) * scale;
            double sta2 = Convert.ToDouble(data["sta2"]) * pi / 180;
            double sta3 = Convert.ToDouble(data["sta3"]) * pi / 180;
            double sta4 = Convert.ToDouble(data["sta4"]) * pi / 180;
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double dconms = Convert.ToDouble(data["dconms"]) * scale;
            double ls = Convert.ToDouble(data["ls"]) * scale;
            double sig = Convert.ToDouble(data["sig"]) * pi / 180;
            double df = Convert.ToDouble(data["df"]) * scale;
            double flgt = Convert.ToDouble(data["flgt"]) * scale;
            double lcf = Convert.ToDouble(data["lcf"]) * scale;
            double rcf = Convert.ToDouble(data["rcf"]) * scale;
            double nos = Convert.ToDouble(data["nos"]);
            double dcintf = Convert.ToDouble(data["dcintf"]) * scale;
            double pl = (dc1-dcintf) / 2 / Math.Tan(sig / 2);
            double lpr = oal - ls;
            double isframe = Convert.ToDouble(data["isframe"]);
            //主视图
            if (nos == 4)
            {
                //坐标
                Vector2 v1 = new Vector2(dconms / 2 - 0.5, 0);
                Vector2 v2 = new Vector2(dconms / 2, -0.5);
                Vector2 v3 = new Vector2(v2.X, -ls);
                Vector2 v4 = new Vector2(df / 2, v3.Y);
                Vector2 v5 = new Vector2(v4.X, v4.Y - flgt);
                Vector2 v6 = new Vector2(bd4 / 2, v5.Y);
                Vector2 v7 = new Vector2(v6.X, -oal + lcf);
                Vector2 v8 = new Vector2(v7.X - rcf, v7.Y - rcf);
                Vector2 v9 = new Vector2(v8.X, -oal + pl + (dc1 - bd1) / 2 * Math.Tan(sig / 2) - (bd1 - dcintf) / 2 / Math.Tan(sig / 2));
                Vector2 v10 = new Vector2(v7.X, -oal + sd4 + (dc4 - bd4) / 2 * Math.Tan(sta4 / 2));
                Vector2 v11 = new Vector2(dc4 / 2, -oal + sd4);
                Vector2 v33 = new Vector2(v10.X, v11.Y);
                Vector2 v34 = new Vector2(bd3 / 2, v33.Y - (bd4 - bd3) / 2 / Math.Tan(sta4 / 2));
                Vector2 v12 = new Vector2(dc3 / 2, v34.Y - (v11.X - v33.X - (dc3 - bd3) / 2) / Math.Tan(sta4 / 2));
                Vector2 v35 = new Vector2(v34.X, -oal + sd3);
                Vector2 v13 = new Vector2(v12.X, v35.Y - (v12.X - v34.X) / Math.Tan(pi / 2 - sta3 / 4));
                Vector2 v36 = new Vector2(bd2 / 2, v35.Y - (bd3 - bd2) / 2 / Math.Tan(sta3 / 2));
                Vector2 v14 = new Vector2(dc2 / 2, v13.Y - (dc3 - dc2) / 2 / Math.Tan(sta3 / 2));
                Vector2 v37 = new Vector2(v36.X, -oal + pl + sdl1 + (bd2 - bd1) / 2 * Math.Cos(sta2 / 2) / Math.Sin(sta2 / 2));
                Vector2 v15 = new Vector2(v14.X, v37.Y - v14.X + v36.X);
                Vector2 v38 = new Vector2(bd1 / 2, -oal + pl + sdl1);
                Vector2 v16 = new Vector2(dc1 / 2, v15.Y - (dc2 - dc1) / 2 / Math.Tan(sta2 / 2));
                Vector2 v17 = new Vector2(v16.X, -oal + pl);
                Vector2 v39 = new Vector2(v38.X, v17.Y + (dc1 - bd1) / 2 * Math.Tan(sig / 2));
                Vector2 v18 = new Vector2(dcintf / 2, -oal);
                Vector2 v60 = new Vector2(v18.X, v39.Y - (bd1 - dcintf) / 2 / Math.Tan(sig / 2));
                Vector2 v57 = new Vector2(v60.X - (v60.Y - v18.Y) / Math.Tan(sig / 2), v60.Y);
                Vector2 v58 = new Vector2(-v57.X, v57.Y);
                Vector2 v59 = new Vector2(-v18.X, v18.Y);
                Vector2 v61 = new Vector2(-v60.X, v60.Y);
                Vector2 v19 = new Vector2(-v17.X, v17.Y);
                Vector2 v20 = new Vector2(-v16.X, v16.Y);
                Vector2 v21 = new Vector2(-v15.X, v15.Y);
                Vector2 v22 = new Vector2(-v14.X, v14.Y);
                Vector2 v23 = new Vector2(-v13.X, v13.Y);
                Vector2 v24 = new Vector2(-v12.X, v12.Y);
                Vector2 v25 = new Vector2(-v11.X, v11.Y);
                Vector2 v26 = new Vector2(-v10.X, v10.Y);
                Vector2 v27 = new Vector2(-v6.X, v6.Y);
                Vector2 v28 = new Vector2(-v5.X, v5.Y);
                Vector2 v29 = new Vector2(-v4.X, v4.Y);
                Vector2 v30 = new Vector2(-v3.X, v3.Y);
                Vector2 v31 = new Vector2(-v2.X, v2.Y);
                Vector2 v32 = new Vector2(-v1.X, v1.Y);
                Vector2 v40 = new Vector2(-v39.X, v39.Y);
                Vector2 v41 = new Vector2(-v38.X, v38.Y);
                Vector2 v42 = new Vector2(-v37.X, v37.Y);
                Vector2 v43 = new Vector2(-v36.X, v36.Y);
                Vector2 v44 = new Vector2(-v35.X, v35.Y);
                Vector2 v45 = new Vector2(-v34.X, v34.Y);
                Vector2 v46 = new Vector2(-v33.X, v33.Y);
                Vector2 v47 = new Vector2(0, 2);
                Vector2 v48 = new Vector2(0, -oal - 2);
                double x51 = bd4 / 2 - rcf;
                if (v46.Y > v8.Y)
                {
                    x51 = v6.X - Math.Sqrt(rcf * rcf - (v46.Y - v8.Y) * (v46.Y - v8.Y));
                }
                double x52 = bd4 / 2 - rcf;
                if (v45.Y > v8.Y)
                {
                    x52 = v6.X - Math.Sqrt(rcf * rcf - (v45.Y - v8.Y) * (v45.Y - v8.Y));
                }
                double x53 = bd4 / 2 - rcf;
                if (v44.Y > v8.Y)
                {
                    x53 = v6.X - Math.Sqrt(rcf * rcf - (v44.Y - v8.Y) * (v44.Y - v8.Y));
                }
                double x54 = bd4 / 2 - rcf;
                if (v43.Y > v8.Y)
                {
                    x54 = v6.X - Math.Sqrt(rcf * rcf - (v43.Y - v8.Y) * (v43.Y - v8.Y));
                }
                double x55 = bd4 / 2 - rcf;
                if (v42.Y > v8.Y)
                {
                    x55 = v6.X - Math.Sqrt(rcf * rcf - (v42.Y - v8.Y) * (v42.Y - v8.Y));
                }
                double x56 = bd4 / 2 - rcf;
                if (v41.Y > v8.Y)
                {
                    x56 = v6.X - Math.Sqrt(rcf * rcf - (v41.Y - v8.Y) * (v41.Y - v8.Y));
                }
                Vector2 v51 = new Vector2(x51, v46.Y);
                Vector2 v52 = new Vector2(x52, v45.Y);
                Vector2 v53 = new Vector2(x53, v44.Y);
                Vector2 v54 = new Vector2(x54, v43.Y);
                Vector2 v55 = new Vector2(x55, v42.Y);
                Vector2 v56 = new Vector2(x56, v41.Y);
                double x62 = bd4 / 2 - rcf;
                if (v40.Y > v8.Y)
                {
                    x62 = v6.X - Math.Sqrt(rcf * rcf - (v40.Y - v8.Y) * (v40.Y - v8.Y));
                }
                Vector2 v62 = new Vector2(x62, v40.Y);
                //线段
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                Vector2[] Line3 = { v3, v4 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v4, v5 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v5, v6 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v6, v33 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                Vector2[] Line7 = { v33, v34 };
                fun.drawBLine(dxf, Line7, 0.3, contour);
                Vector2[] Line8 = { v34, v35 };
                fun.drawBLine(dxf, Line8, 0.3, contour);
                Vector2[] Line9 = { v35, v36 };
                fun.drawBLine(dxf, Line9, 0.3, contour);
                Vector2[] Line10 = { v36, v37 };
                fun.drawBLine(dxf, Line10, 0.3, contour);
                Vector2[] Line11 = { v37, v38 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
                Vector2[] Line12 = { v38, v39 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line13 = { v10, v11 };
                fun.drawPlinetype(dxf, Line13, 0.15, refin, Linetype.Dashed);
                Vector2[] Line14 = { v11, v12 };
                fun.drawPlinetype(dxf, Line14, 0.15, refin, Linetype.Dashed);
                Vector2[] Line15 = { v12, v13 };
                fun.drawPlinetype(dxf, Line15, 0.15, refin, Linetype.Dashed);
                Vector2[] Line16 = { v13, v14 };
                fun.drawPlinetype(dxf, Line16, 0.15, refin, Linetype.Dashed);
                Vector2[] Line17 = { v14, v15 };
                fun.drawPlinetype(dxf, Line17, 0.15, refin, Linetype.Dashed);
                Vector2[] Line18 = { v15, v16 };
                fun.drawPlinetype(dxf, Line18, 0.15, refin, Linetype.Dashed);
                Vector2[] Line19 = { v16, v17 };
                fun.drawPlinetype(dxf, Line19, 0.15, refin, Linetype.Dashed);
                Vector2[] Line20 = { v17, v18 };
                fun.drawPlinetype(dxf, Line20, 0.15, refin, Linetype.Dashed);
                Vector2[] Line21 = { v39, v60 };
                fun.drawBLine(dxf, Line21, 0.3, contour);
                Vector2[] Line22 = { v57, v18 };
                fun.drawPlinetype(dxf, Line22, 0.15, refin, Linetype.Dashed);
                Vector2[] Line23 = { v58, v59 };
                fun.drawPlinetype(dxf, Line23, 0.15, refin, Linetype.Dashed);
                Vector2[] Line24 = { v19, v59 };
                fun.drawPlinetype(dxf, Line24, 0.15, refin, Linetype.Dashed);
                Vector2[] Line25 = { v19, v20 };
                fun.drawPlinetype(dxf, Line25, 0.15, refin, Linetype.Dashed);
                Vector2[] Line26 = { v20, v21 };
                fun.drawPlinetype(dxf, Line26, 0.15, refin, Linetype.Dashed);
                Vector2[] Line27 = { v21, v22 };
                fun.drawPlinetype(dxf, Line27, 0.15, refin, Linetype.Dashed);
                Vector2[] Line28 = { v22, v23 };
                fun.drawPlinetype(dxf, Line28, 0.15, refin, Linetype.Dashed);
                Vector2[] Line29 = { v23, v24 };
                fun.drawPlinetype(dxf, Line29, 0.15, refin, Linetype.Dashed);
                Vector2[] Line30 = { v24, v25 };
                fun.drawPlinetype(dxf, Line30, 0.15, refin, Linetype.Dashed);
                Vector2[] Line31 = { v25, v26 };
                fun.drawPlinetype(dxf, Line31, 0.15, refin, Linetype.Dashed);
                Vector2[] Line32 = { v27, v46 };
                fun.drawBLine(dxf, Line32, 0.3, contour);
                Vector2[] Line33 = { v46, v45 };
                fun.drawBLine(dxf, Line33, 0.3, contour);
                Vector2[] Line34 = { v45, v44 };
                fun.drawBLine(dxf, Line34, 0.3, contour);
                Vector2[] Line35 = { v44, v43 };
                fun.drawBLine(dxf, Line35, 0.3, contour);
                Vector2[] Line36 = { v43, v42 };
                fun.drawBLine(dxf, Line36, 0.3, contour);
                Vector2[] Line37 = { v42, v41 };
                fun.drawBLine(dxf, Line37, 0.3, contour);
                Vector2[] Line38 = { v41, v40 };
                fun.drawBLine(dxf, Line38, 0.3, contour);
                Vector2[] Line54 = { v61, v40 };
                fun.drawBLine(dxf, Line54, 0.3, contour);
                Vector2[] Line55 = { v61, v60 };
                fun.drawBLine(dxf, Line55, 0.3, contour);
                Vector2[] Line39 = { v27, v28 };
                fun.drawBLine(dxf, Line39, 0.3, contour);
                Vector2[] Line40 = { v28, v29 };
                fun.drawBLine(dxf, Line40, 0.3, contour);
                Vector2[] Line41 = { v29, v30 };
                fun.drawBLine(dxf, Line41, 0.3, contour);
                Vector2[] Line42 = { v30, v31 };
                fun.drawBLine(dxf, Line42, 0.3, contour);
                Vector2[] Line43 = { v31, v32 };
                fun.drawBLine(dxf, Line43, 0.3, contour);
                Vector2[] Line44 = { v32, v1 };
                fun.drawBLine(dxf, Line44, 0.3, contour);
                Vector2[] Line45 = { v31, v2 };
                fun.drawBLine(dxf, Line45, 0.3, contour);
                Vector2[] Line46 = { v30, v3 };
                fun.drawBLine(dxf, Line46, 0.3, contour);
                Vector2[] Line47 = { v27, v6 };
                fun.drawBLine(dxf, Line47, 0.3, contour);
                Vector2[] Line48 = { v46, v51 };
                fun.drawBLine(dxf, Line48, 0.3, contour);
                Vector2[] Line49 = { v45, v52 };
                fun.drawBLine(dxf, Line49, 0.3, contour);
                Vector2[] Line50 = { v44, v53 };
                fun.drawBLine(dxf, Line50, 0.3, contour);
                Vector2[] Line51 = { v43, v54 };
                fun.drawBLine(dxf, Line51, 0.3, contour);
                Vector2[] Line52 = { v42, v55 };
                fun.drawBLine(dxf, Line52, 0.3, contour);
                Vector2[] Line53 = { v47, v48 };
                fun.drawPlinetype(dxf, Line53, 0.15, center, Linetype.Center);
                Vector2[] Line56 = { v8, v9 };
                fun.drawBLine(dxf, Line56, 0.3, contour);
                Vector2[] Line57 = { v41, v56 };
                fun.drawBLine(dxf, Line57, 0.3, contour);
                Vector2[] Line58 = { v40, v62 };
                fun.drawBLine(dxf, Line58, 0.3, contour);
                LwPolyline Arc1 = new LwPolyline();
                Arc1.Vertexes.Add(new LwPolylineVertex(v7));
                Arc1.Vertexes.Add(new LwPolylineVertex(v8));
                Arc1.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * 2 * Math.Cos(pi / 4);
                fun.PolyFill(dxf, Arc1, 0.3, contour);
                Arc Arc2 = new Arc(new Vector2(v7.X, v8.Y), rcf, 90, 180);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 1.0;
                double offset = 10;
                //线段尺寸标注
                //尺寸1
                Angular2LineDimension angdim1 = new Angular2LineDimension(new Line(v59, v19), new Line(v18, v17), v17.X / Math.Sin(sig / 2) * Math.Cos(sig / 2), dimensionStyle);
                angdim1.UserText = "SIG = " + Math.Round(sig / (pi / 180), 2) + "°";
                dxf.AddEntity(angdim1);
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(v17, v19), -pl - offset, 0, dimensionStyle);
                dim2.UserText = "DC_1 = " + Math.Round(dc1 / scale, 2);
                dxf.AddEntity(dim2);
                //尺寸3
                LinearDimension dim3 = new LinearDimension(new Line(v15, v21), -v15.Y + v18.Y - offset * 2 -5, 0, dimensionStyle);
                dim3.UserText = "DC_2 = " + Math.Round(dc2 / scale, 2);
                dxf.AddEntity(dim3);
                //尺寸4
                LinearDimension dim4 = new LinearDimension(new Line(v13, v23), -v13.Y + v18.Y - offset * 2-20, 0, dimensionStyle);
                dim4.UserText = "DC_3 = " + Math.Round(dc3 / scale, 2);
                dxf.AddEntity(dim4);
                //尺寸5
                LinearDimension dim5 = new LinearDimension(new Line(v59, v19), -offset - v4.X + (v17.X + v18.X) / 2, 270, dimensionStyle);
                dim5.UserText = "PL = " + Math.Round(pl / scale, 2);
                dxf.AddEntity(dim5);
                //尺寸6
                LinearDimension dim6 = new LinearDimension(new Line(v1, v3), offset + 0.25 + v4.X - v3.X, 270, dimensionStyle);
                dim6.UserText = "LS = " + Math.Round(ls / scale, 2);
                dxf.AddEntity(dim6);
                //尺寸7
                LinearDimension dim7 = new LinearDimension(new Line(v41, v19), -offset - (v4.X - (v38.X + v17.X) / 2), 270, dimensionStyle);
                dim7.UserText = "SDL_1 = " + Math.Round(sdl1 / scale, 2);
                dxf.AddEntity(dim7);
                //尺寸8
                LinearDimension dim8 = new LinearDimension(new Line(v35, v18), offset + v4.X - (v35.X + v18.X) / 2, 270, dimensionStyle);
                dim8.UserText = "SD_3 = " + Math.Round(sd3 / scale, 2);
                dxf.AddEntity(dim8);
                //尺寸9
                LinearDimension dim9 = new LinearDimension(new Line(v18, v1), offset * 5 + v4.X - (v1.X + v18.X) / 2 + 0.25, 270, dimensionStyle);
                dim9.UserText = "OAL = " + Math.Round(oal / scale, 2);
                dxf.AddEntity(dim9);
                //尺寸10
                LinearDimension dim10 = new LinearDimension(new Line(v31, v2), offset + 0.5, 0, dimensionStyle);
                dim10.UserText = "DCONMS = " + Math.Round(dconms / scale, 2);
                dxf.AddEntity(dim10);
                //尺寸11
                if (sta2 != pi)
                {
                    Angular2LineDimension angdim11 = new Angular2LineDimension(new Line(v41, v42), new Line(v38, v37), v37.X / Math.Sin(sta2 / 2) * Math.Cos(sta2 / 2) + offset, dimensionStyle);
                    angdim11.UserText = "STA_2 = " + Math.Round(sta2 / (pi / 180), 2) + "°";
                    dxf.AddEntity(angdim11);
                }
                if (sta2 == pi)
                {
                    Angular2LineDimension angdim11 = new Angular2LineDimension(new Line(v41, new Vector2(v42.X, v42.Y + 0.1)), new Line(v38, new Vector2(v37.X, v37.Y + 0.1)), v37.X / Math.Sin(sta2 / 2) * Math.Cos(sta2 / 2) + offset, dimensionStyle);
                    angdim11.UserText = "STA_2 = " + Math.Round(sta2 / (pi / 180), 2) + "°";
                    dxf.AddEntity(angdim11);
                }
                //尺寸12
                /*Angular2LineDimension angdim12 = new Angular2LineDimension(new Line(v43, v44), new Line(v36, v35), v36.X / Math.Sin(sta3 / 2)* Math.Cos(sta3 / 2) + offset, dimensionStyle);
                angdim12.UserText = "STA_3 = " + Math.Round(sta3 / (pi / 180), 2) + "°";
                dxf.AddEntity(angdim12);*/
                if (sta3 != pi)
                {
                    Angular2LineDimension angdim12 = new Angular2LineDimension(new Line(v43, v44), new Line(v36, v35), v35.X / Math.Sin(sta3 / 2) * Math.Cos(sta3 / 2) + offset, dimensionStyle);
                    angdim12.UserText = "STA_3 = " + Math.Round(sta3 / (pi / 180), 2) + "°";
                    dxf.AddEntity(angdim12);
                }
                if (sta3 == pi)
                {
                    Angular2LineDimension angdim12 = new Angular2LineDimension(new Line(v43, new Vector2(v44.X, v44.Y + 0.1)), new Line(v36, new Vector2(v35.X, v35.Y + 0.1)), v35.X / Math.Sin(sta3 / 2) * Math.Cos(sta3 / 2) + offset, dimensionStyle);
                    angdim12.UserText = "STA_3 = " + Math.Round(sta3 / (pi / 180), 2) + "°";
                    dxf.AddEntity(angdim12);
                }
                //尺寸13
                LinearDimension dim13 = new LinearDimension(new Line(v11, v25), -v11.Y + v18.Y - offset * 3 - 30, 0, dimensionStyle);
                dim13.UserText = "DC_4 = " + Math.Round(dc4 / scale, 2);
                dxf.AddEntity(dim13);
                //尺寸14
                LinearDimension dim14 = new LinearDimension(new Line(v33, v18), offset * 2 + v4.X - (v33.X + v18.X) / 2, 270, dimensionStyle);
                dim14.UserText = "SD_4 = " + Math.Round(sd4 / scale, 2);
                dxf.AddEntity(dim14);
                //尺寸15
                Angular2LineDimension angdim15 = new Angular2LineDimension(new Line(v45, v46), new Line(v34, v33), v33.X / Math.Sin(sta4 / 2) * Math.Cos(sta3 / 2) + offset, dimensionStyle);
                angdim15.UserText = "STA_4 = " + Math.Round(sta4 / (pi / 180), 2) + "°";
                dxf.AddEntity(angdim15);
                //尺寸16
                LinearDimension dim16 = new LinearDimension(new Line(v4, v5), offset, 270, dimensionStyle);
                dim16.UserText = "FLGT = " + Math.Round(flgt / scale, 2);
                dxf.AddEntity(dim16);
                //尺寸17
                LinearDimension dim17 = new LinearDimension(new Line(v7, v18), offset * 3 - (v7.X + v18.X) / 2 + v4.X, 270, dimensionStyle);
                dim17.UserText = "LCF = " + Math.Round(lcf / scale, 2);
                dxf.AddEntity(dim17);
                //尺寸18
                LinearDimension dim18 = new LinearDimension(new Line(v4, v18), offset * 4 + (v4.X - v18.X) / 2, 270, dimensionStyle);
                dim18.UserText = "LPR = " + Math.Round(lpr / scale, 2);
                dxf.AddEntity(dim18);
                //尺寸19
                LinearDimension dim19 = new LinearDimension(new Line(v29, v4), -flgt / 2, 0, dimensionStyle);
                dim19.UserText = "DF = " + Math.Round(df / scale, 2);
                dxf.AddEntity(dim19);
                //尺寸20
                LinearDimension dim20 = new LinearDimension(new Line(v27, v6), -(v27.Y - v46.Y) / 2, 0, dimensionStyle);
                dim20.UserText = "BD_4 = " + Math.Round(bd4 / scale, 2);
                dxf.AddEntity(dim20);
                //尺寸21
                LinearDimension dim21 = new LinearDimension(new Line(v45, v34), -(v45.Y - v44.Y), 0, dimensionStyle);
                dim21.UserText = "BD_3 = " + Math.Round(bd3 / scale, 2);
                dxf.AddEntity(dim21);
                //尺寸22
                LinearDimension dim22 = new LinearDimension(new Line(v43, v36), -(v43.Y - v42.Y), 0, dimensionStyle);
                dim22.UserText = "BD_2 = " + Math.Round(bd2 / scale, 2);
                dxf.AddEntity(dim22);
                //尺寸23
                LinearDimension dim23 = new LinearDimension(new Line(v41, v38), -(v41.Y - v40.Y) / 2, 0, dimensionStyle);
                dim23.UserText = "BD_1 = " + Math.Round(bd1 / scale, 2);
                dxf.AddEntity(dim23);
                //尺寸24
                RadialDimension dimrad24 = new RadialDimension(Arc2, 135, 0, dimensionStyle);//DimensionStyle.Default);
                dimrad24.UserText = "RCF = " + Math.Round(rcf / scale, 2);
                dxf.AddEntity(dimrad24);
            }
            if (nos == 3)
            {
                //坐标
                Vector2 v1 = new Vector2(dconms / 2 - 0.5, 0);
                Vector2 v2 = new Vector2(dconms / 2, -0.5);
                Vector2 v3 = new Vector2(v2.X, -ls);
                Vector2 v4 = new Vector2(df / 2, v3.Y);
                Vector2 v5 = new Vector2(v4.X, v4.Y - flgt);
                Vector2 v6 = new Vector2(bd3 / 2, v5.Y);
                Vector2 v7 = new Vector2(v6.X, -oal + lcf);
                Vector2 v8 = new Vector2(v7.X - rcf, v7.Y - rcf);
                Vector2 v9 = new Vector2(v8.X, -oal + pl + (dc1 - bd1) / 2 * Math.Tan(sig / 2) - (bd1 - dcintf) / 2 / Math.Tan(sig / 2));
                Vector2 v10 = new Vector2(v7.X, -oal + sd3 + (dc3 - bd3) / 2 * Math.Tan(sta3 / 2));
                Vector2 v11 = new Vector2(dc3 / 2, -oal + sd3);
                Vector2 v35 = new Vector2(v10.X, v11.Y);
                Vector2 v36 = new Vector2(bd2 / 2, v35.Y - (bd3 - bd2) / 2 / Math.Tan(sta3 / 2));
                Vector2 v14 = new Vector2(dc2 / 2, v11.Y - (dc3 - dc2) / 2 / Math.Tan(sta3 / 2));
                Vector2 v37 = new Vector2(v36.X, -oal + pl + sdl1 + (bd2 - bd1) / 2 * Math.Cos(sta2 / 2) / Math.Sin(sta2 / 2));
                Vector2 v15 = new Vector2(v14.X, v37.Y - v14.X + v36.X);
                Vector2 v38 = new Vector2(bd1 / 2, -oal + pl + sdl1);
                Vector2 v16 = new Vector2(dc1 / 2, v15.Y - (dc2 - dc1) / 2 / Math.Tan(sta2 / 2));
                Vector2 v17 = new Vector2(v16.X, -oal + pl);
                Vector2 v39 = new Vector2(v38.X, v17.Y + (dc1 - bd1) / 2 * Math.Tan(sig / 2));
                Vector2 v18 = new Vector2(dcintf / 2, -oal);
                Vector2 v19 = new Vector2(-v17.X, v17.Y);
                Vector2 v20 = new Vector2(-v16.X, v16.Y);
                Vector2 v21 = new Vector2(-v15.X, v15.Y);
                Vector2 v22 = new Vector2(-v14.X, v14.Y);
                Vector2 v25 = new Vector2(-v11.X, v11.Y);
                Vector2 v26 = new Vector2(-v10.X, v10.Y);
                Vector2 v27 = new Vector2(-v6.X, v6.Y);
                Vector2 v28 = new Vector2(-v5.X, v5.Y);
                Vector2 v29 = new Vector2(-v4.X, v4.Y);
                Vector2 v30 = new Vector2(-v3.X, v3.Y);
                Vector2 v31 = new Vector2(-v2.X, v2.Y);
                Vector2 v32 = new Vector2(-v1.X, v1.Y);
                Vector2 v40 = new Vector2(-v39.X, v39.Y);
                Vector2 v41 = new Vector2(-v38.X, v38.Y);
                Vector2 v42 = new Vector2(-v37.X, v37.Y);
                Vector2 v43 = new Vector2(-v36.X, v36.Y);
                Vector2 v46 = new Vector2(-v35.X, v35.Y);
                Vector2 v47 = new Vector2(0, 2);
                Vector2 v48 = new Vector2(0, -oal - 2);
                Vector2 v49 = new Vector2(v19.X, 2 * v18.Y - v19.Y);
                Vector2 v50 = new Vector2(v17.X, 2 * v18.Y - v17.Y);
                double x51 = bd3 / 2 - rcf;
                if (v46.Y > v8.Y)
                {
                    x51 = v6.X - Math.Sqrt(rcf * rcf - (v46.Y - v8.Y) * (v46.Y - v8.Y));
                }
                double x54 = bd3 / 2 - rcf;
                if (v43.Y > v8.Y)
                {
                    x54 = v6.X - Math.Sqrt(rcf * rcf - (v43.Y - v8.Y) * (v43.Y - v8.Y));
                }
                double x55 = bd3 / 2 - rcf;
                if (v41.Y > v8.Y)
                {
                    x55 = v6.X - Math.Sqrt(rcf * rcf - (v41.Y - v8.Y) * (v41.Y - v8.Y));
                }
                double x56 = bd3 / 2 - rcf;
                if (v42.Y > v8.Y)
                {
                    x56 = v6.X - Math.Sqrt(rcf * rcf - (v42.Y - v8.Y) * (v42.Y - v8.Y));
                }
                Vector2 v51 = new Vector2(x51, v46.Y);
                Vector2 v54 = new Vector2(x54, v43.Y);
                Vector2 v55 = new Vector2(x55, v41.Y);
                Vector2 v56 = new Vector2(x56, v42.Y);
                Vector2 v60 = new Vector2(v18.X, v39.Y - (bd1 - dcintf) / 2 / Math.Tan(sig / 2));
                Vector2 v57 = new Vector2(v60.X - (v60.Y - v18.Y) / Math.Tan(sig / 2), v60.Y);
                Vector2 v58 = new Vector2(-v57.X, v57.Y);
                Vector2 v59 = new Vector2(-v18.X, v18.Y);
                Vector2 v61 = new Vector2(-v60.X, v60.Y);
                double x62 = bd3 / 2 - rcf;
                if (v40.Y > v8.Y)
                {
                    x62 = v6.X - Math.Sqrt(rcf * rcf - (v40.Y - v8.Y) * (v40.Y - v8.Y));
                }
                Vector2 v62 = new Vector2(x62, v40.Y);
                //线段
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                Vector2[] Line3 = { v3, v4 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v4, v5 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v5, v6 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v6, v35 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                Vector2[] Line9 = { v35, v36 };
                fun.drawBLine(dxf, Line9, 0.3, contour);
                Vector2[] Line10 = { v36, v37 };
                fun.drawBLine(dxf, Line10, 0.3, contour);
                Vector2[] Line11 = { v37, v38 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
                Vector2[] Line12 = { v38, v39 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line13 = { v10, v11 };
                fun.drawPlinetype(dxf, Line13, 0.15, refin, Linetype.Dashed);
                Vector2[] Line16 = { v11, v14 };
                fun.drawPlinetype(dxf, Line16, 0.15, refin, Linetype.Dashed);
                Vector2[] Line17 = { v14, v15 };
                fun.drawPlinetype(dxf, Line17, 0.15, refin, Linetype.Dashed);
                Vector2[] Line18 = { v15, v16 };
                fun.drawPlinetype(dxf, Line18, 0.15, refin, Linetype.Dashed);
                Vector2[] Line19 = { v16, v17 };
                fun.drawPlinetype(dxf, Line19, 0.15, refin, Linetype.Dashed);
                Vector2[] Line20 = { v17, v18 };
                fun.drawPlinetype(dxf, Line20, 0.15, refin, Linetype.Dashed);
                Vector2[] Line21 = { v62, v40 };
                fun.drawBLine(dxf, Line21, 0.3, contour);
                Vector2[] Line22 = { v18, v57 };
                fun.drawPlinetype(dxf, Line22, 0.15, refin, Linetype.Dashed);
                Vector2[] Line23 = { v58, v59 };
                fun.drawPlinetype(dxf, Line23, 0.15, refin, Linetype.Dashed);
                Vector2[] Line24 = { v19, v59 };
                fun.drawPlinetype(dxf, Line24, 0.15, refin, Linetype.Dashed);
                Vector2[] Line25 = { v19, v20 };
                fun.drawPlinetype(dxf, Line25, 0.15, refin, Linetype.Dashed);
                Vector2[] Line26 = { v20, v21 };
                fun.drawPlinetype(dxf, Line26, 0.15, refin, Linetype.Dashed);
                Vector2[] Line27 = { v21, v22 };
                fun.drawPlinetype(dxf, Line27, 0.15, refin, Linetype.Dashed);
                Vector2[] Line28 = { v22, v25 };
                fun.drawPlinetype(dxf, Line28, 0.15, refin, Linetype.Dashed);
                Vector2[] Line31 = { v25, v26 };
                fun.drawPlinetype(dxf, Line31, 0.15, refin, Linetype.Dashed);
                Vector2[] Line32 = { v27, v46 };
                fun.drawBLine(dxf, Line32, 0.3, contour);
                Vector2[] Line33 = { v46, v43 };
                fun.drawBLine(dxf, Line33, 0.3, contour);
                Vector2[] Line36 = { v43, v42 };
                fun.drawBLine(dxf, Line36, 0.3, contour);
                Vector2[] Line37 = { v42, v41 };
                fun.drawBLine(dxf, Line37, 0.3, contour);
                Vector2[] Line38 = { v41, v40 };
                fun.drawBLine(dxf, Line38, 0.3, contour);
                Vector2[] Line39 = { v27, v28 };
                fun.drawBLine(dxf, Line39, 0.3, contour);
                Vector2[] Line40 = { v28, v29 };
                fun.drawBLine(dxf, Line40, 0.3, contour);
                Vector2[] Line41 = { v29, v30 };
                fun.drawBLine(dxf, Line41, 0.3, contour);
                Vector2[] Line42 = { v30, v31 };
                fun.drawBLine(dxf, Line42, 0.3, contour);
                Vector2[] Line43 = { v31, v32 };
                fun.drawBLine(dxf, Line43, 0.3, contour);
                Vector2[] Line44 = { v32, v1 };
                fun.drawBLine(dxf, Line44, 0.3, contour);
                Vector2[] Line45 = { v31, v2 };
                fun.drawBLine(dxf, Line45, 0.3, contour);
                Vector2[] Line46 = { v30, v3 };
                fun.drawBLine(dxf, Line46, 0.3, contour);
                Vector2[] Line47 = { v27, v6 };
                fun.drawBLine(dxf, Line47, 0.3, contour);
                Vector2[] Line48 = { v46, v51 };
                fun.drawBLine(dxf, Line48, 0.3, contour);
                Vector2[] Line51 = { v43, v54 };
                fun.drawBLine(dxf, Line51, 0.3, contour);
                Vector2[] Line52 = { v41, v55 };
                fun.drawBLine(dxf, Line52, 0.3, contour);
                Vector2[] Line53 = { v47, v48 };
                fun.drawPlinetype(dxf, Line53, 0.15, center, Linetype.Center);
                Vector2[] Line56 = { v8, v9 };
                fun.drawBLine(dxf, Line56, 0.3, contour);
                Vector2[] Line57 = { v42, v56 };
                fun.drawBLine(dxf, Line57, 0.3, contour);
                LwPolyline Arc1 = new LwPolyline();
                Arc1.Vertexes.Add(new LwPolylineVertex(v7));
                Arc1.Vertexes.Add(new LwPolylineVertex(v8));
                Arc1.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * 2 * Math.Cos(pi / 4);
                fun.PolyFill(dxf, Arc1, 0.3, contour);
                Arc Arc2 = new Arc(new Vector2(v7.X, v8.Y), rcf, 90, 180);
                Vector2[] Line58 = { v39, v60 };
                fun.drawBLine(dxf, Line58, 0.3, contour);
                Vector2[] Line59 = { v40, v61 };
                fun.drawBLine(dxf, Line59, 0.3, contour);
                Vector2[] Line60 = { v60, v61 };
                fun.drawBLine(dxf, Line60, 0.3, contour);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 1.0;
                double offset = 10;
                //线段尺寸标注
                //尺寸1
                Angular2LineDimension angdim1 = new Angular2LineDimension(new Line(v59, v19), new Line(v18, v17), v17.X / Math.Sin(sig / 2) * Math.Cos(sig / 2), dimensionStyle);
                angdim1.UserText = "SIG = " + Math.Round(sig / (pi / 180), 2) + "°";
                dxf.AddEntity(angdim1);
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(v17, v19), -pl - offset, 0, dimensionStyle);
                dim2.UserText = "DC_1 = " + Math.Round(dc1 / scale, 2);
                dxf.AddEntity(dim2);
                //尺寸3
                LinearDimension dim3 = new LinearDimension(new Line(v15, v21), -v15.Y + v18.Y - offset * 2 + 5, 0, dimensionStyle);
                dim3.UserText = "DC_2 = " + Math.Round(dc2 / scale, 2);
                dxf.AddEntity(dim3);
                //尺寸5
                LinearDimension dim5 = new LinearDimension(new Line(v59, v19), -offset - v4.X + (v17.X + v18.X) / 2, 270, dimensionStyle);
                dim5.UserText = "PL = " + Math.Round(pl / scale, 2);
                dxf.AddEntity(dim5);
                //尺寸6
                LinearDimension dim6 = new LinearDimension(new Line(v1, v3), offset + 0.25 + v4.X - v3.X, 270, dimensionStyle);
                dim6.UserText = "LS = " + Math.Round(ls / scale, 2);
                dxf.AddEntity(dim6);
                //尺寸7
                LinearDimension dim7 = new LinearDimension(new Line(v41, v19), -offset - (v4.X - (v38.X + v17.X) / 2), 270, dimensionStyle);
                dim7.UserText = "SDL_1 = " + Math.Round(sdl1 / scale, 2);
                dxf.AddEntity(dim7);
                //尺寸8
                LinearDimension dim8 = new LinearDimension(new Line(v35, v18), offset + v4.X - (v35.X + v18.X) / 2, 270, dimensionStyle);
                dim8.UserText = "SD_3 = " + Math.Round(sd3 / scale, 2);
                dxf.AddEntity(dim8);
                //尺寸9
                LinearDimension dim9 = new LinearDimension(new Line(v18, v1), offset * 4 + v4.X - (v1.X + v18.X) / 2 + 0.25, 270, dimensionStyle);
                dim9.UserText = "OAL = " + Math.Round(oal / scale, 2);
                dxf.AddEntity(dim9);
                //尺寸10
                LinearDimension dim10 = new LinearDimension(new Line(v31, v2), offset + 0.5, 0, dimensionStyle);
                dim10.UserText = "DCONMS = " + Math.Round(dconms / scale, 2);
                dxf.AddEntity(dim10);
                //尺寸11
                if (sta2 != pi)
                {
                    Angular2LineDimension angdim11 = new Angular2LineDimension(new Line(v41, v42), new Line(v38, v37), v37.X / Math.Sin(sta2 / 2) * Math.Cos(sta2 / 2) + offset, dimensionStyle);
                    angdim11.UserText = "STA_2 = " + Math.Round(sta2 / (pi / 180), 2) + "°";
                    dxf.AddEntity(angdim11);
                }
                if (sta2 == pi)
                {
                    Angular2LineDimension angdim11 = new Angular2LineDimension(new Line(v41, new Vector2(v42.X, v42.Y + 0.1)), new Line(v38, new Vector2(v37.X, v37.Y + 0.1)), v37.X / Math.Sin(sta2 / 2) * Math.Cos(sta2 / 2) + offset, dimensionStyle);
                    angdim11.UserText = "STA_2 = " + Math.Round(sta2 / (pi / 180), 2) + "°";
                    dxf.AddEntity(angdim11);
                }
                //尺寸12
                /*Angular2LineDimension angdim12 = new Angular2LineDimension(new Line(v43, v44), new Line(v36, v35), v36.X / Math.Sin(sta3 / 2)* Math.Cos(sta3 / 2) + offset, dimensionStyle);
                angdim12.UserText = "STA_3 = " + Math.Round(sta3 / (pi / 180), 2) + "°";
                dxf.AddEntity(angdim12);*/
                if (sta3 != pi)
                {
                    Angular2LineDimension angdim12 = new Angular2LineDimension(new Line(v43, v46), new Line(v36, v35), v35.X / Math.Sin(sta3 / 2) * Math.Cos(sta3 / 2) + offset, dimensionStyle);
                    angdim12.UserText = "STA_3 = " + Math.Round(sta3 / (pi / 180), 2) + "°";
                    dxf.AddEntity(angdim12);
                }
                if (sta3 == pi)
                {
                    Angular2LineDimension angdim12 = new Angular2LineDimension(new Line(v43, new Vector2(v46.X, v46.Y + 0.1)), new Line(v36, new Vector2(v35.X, v35.Y + 0.1)), v35.X / Math.Sin(sta3 / 2) * Math.Cos(sta3 / 2) + offset, dimensionStyle);
                    angdim12.UserText = "STA_3 = " + Math.Round(sta3 / (pi / 180), 2) + "°";
                    dxf.AddEntity(angdim12);
                }
                //尺寸13
                LinearDimension dim13 = new LinearDimension(new Line(v11, v25), -v11.Y + v18.Y - offset * 2, 0, dimensionStyle);
                dim13.UserText = "DC_3 = " + Math.Round(dc3 / scale, 2);
                dxf.AddEntity(dim13);
                //尺寸16
                LinearDimension dim16 = new LinearDimension(new Line(v4, v5), offset, 270, dimensionStyle);
                dim16.UserText = "FLGT = " + Math.Round(flgt / scale, 2);
                dxf.AddEntity(dim16);
                //尺寸17
                LinearDimension dim17 = new LinearDimension(new Line(v7, v18), offset * 2 - (v7.X + v18.X) / 2 + v4.X, 270, dimensionStyle);
                dim17.UserText = "LCF = " + Math.Round(lcf / scale, 2);
                dxf.AddEntity(dim17);
                //尺寸18
                LinearDimension dim18 = new LinearDimension(new Line(v4, v18), offset * 3 + (v4.X - v18.X) / 2, 270, dimensionStyle);
                dim18.UserText = "LPR = " + Math.Round(lpr / scale, 2);
                dxf.AddEntity(dim18);
                //尺寸19
                LinearDimension dim19 = new LinearDimension(new Line(v29, v4), -flgt / 2, 0, dimensionStyle);
                dim19.UserText = "DF = " + Math.Round(df / scale, 2);
                dxf.AddEntity(dim19);
                //尺寸20
                LinearDimension dim20 = new LinearDimension(new Line(v27, v6), -(v27.Y - v46.Y) / 2, 0, dimensionStyle);
                dim20.UserText = "BD_3 = " + Math.Round(bd3 / scale, 2);
                dxf.AddEntity(dim20);
                //尺寸22
                LinearDimension dim22 = new LinearDimension(new Line(v43, v36), -(v43.Y - v42.Y), 0, dimensionStyle);
                dim22.UserText = "BD_2 = " + Math.Round(bd2 / scale, 2);
                dxf.AddEntity(dim22);
                //尺寸23
                LinearDimension dim23 = new LinearDimension(new Line(v41, v38), -(v41.Y - v40.Y) / 2, 0, dimensionStyle);
                dim23.UserText = "BD_1 = " + Math.Round(bd1 / scale, 2);
                dxf.AddEntity(dim23);
                //尺寸24
                RadialDimension dimrad24 = new RadialDimension(Arc2, 135, 0, dimensionStyle);//DimensionStyle.Default);
                dimrad24.UserText = "RCF = " + Math.Round(rcf / scale, 2);
                dxf.AddEntity(dimrad24);
            }
            if (nos == 2)
            {
                //坐标
                Vector2 v1 = new Vector2(dconms / 2 - 0.5, 0);
                Vector2 v2 = new Vector2(dconms / 2, -0.5);
                Vector2 v3 = new Vector2(v2.X, -ls);
                Vector2 v4 = new Vector2(df / 2, v3.Y);
                Vector2 v5 = new Vector2(v4.X, v4.Y - flgt);
                Vector2 v6 = new Vector2(bd2 / 2, v5.Y);
                Vector2 v7 = new Vector2(v6.X, -oal + lcf);
                Vector2 v8 = new Vector2(v7.X - rcf, v7.Y - rcf);
                Vector2 v9 = new Vector2(v8.X, -oal + pl + (dc1 - bd1) / 2 * Math.Tan(sig / 2) - (bd1 - dcintf) / 2 / Math.Tan(sig / 2));
                Vector2 v10 = new Vector2(v7.X, -oal + pl + sdl1 + (dc2 - bd2) / 2 * Math.Tan(sta2 / 2) + (bd2 - bd1) / 2 / Math.Tan(sta2 / 2));
                Vector2 v11 = new Vector2(dc2 / 2, v10.Y - (dc2 - bd2) / 2 * Math.Tan(sta2 / 2));
                Vector2 v37 = new Vector2(v10.X, v11.Y);
                Vector2 v38 = new Vector2(bd1 / 2, -oal + pl + sdl1);
                Vector2 v16 = new Vector2(dc1 / 2, v11.Y - (dc2 - dc1) / 2 / Math.Tan(sta2 / 2));
                Vector2 v17 = new Vector2(v16.X, -oal + pl);
                Vector2 v39 = new Vector2(v38.X, v17.Y + (dc1 - bd1) / 2 * Math.Tan(sig / 2));
                Vector2 v18 = new Vector2(dcintf / 2, -oal);
                Vector2 v19 = new Vector2(-v17.X, v17.Y);
                Vector2 v20 = new Vector2(-v16.X, v16.Y);
                Vector2 v25 = new Vector2(-v11.X, v11.Y);
                Vector2 v26 = new Vector2(-v10.X, v10.Y);
                Vector2 v27 = new Vector2(-v6.X, v6.Y);
                Vector2 v28 = new Vector2(-v5.X, v5.Y);
                Vector2 v29 = new Vector2(-v4.X, v4.Y);
                Vector2 v30 = new Vector2(-v3.X, v3.Y);
                Vector2 v31 = new Vector2(-v2.X, v2.Y);
                Vector2 v32 = new Vector2(-v1.X, v1.Y);
                Vector2 v40 = new Vector2(-v39.X, v39.Y);
                Vector2 v41 = new Vector2(-v38.X, v38.Y);
                Vector2 v42 = new Vector2(-v37.X, v37.Y);
                Vector2 v47 = new Vector2(0, 2);
                Vector2 v48 = new Vector2(0, -oal - 2);
                double x55 = bd2 / 2 - rcf;
                if (v41.Y > v8.Y)
                {
                    x55 = v6.X - Math.Sqrt(rcf * rcf - (v41.Y - v8.Y) * (v41.Y - v8.Y));
                }
                double x56 = bd2 / 2 - rcf;
                if (v42.Y > v8.Y)
                {
                    x56 = v6.X - Math.Sqrt(rcf * rcf - (v42.Y - v8.Y) * (v42.Y - v8.Y));
                }
                Vector2 v55 = new Vector2(x55, v41.Y);
                Vector2 v56 = new Vector2(x56, v42.Y);
                Vector2 v60 = new Vector2(v18.X, v39.Y - (bd1 - dcintf) / 2 / Math.Tan(sig / 2));
                Vector2 v57 = new Vector2(v60.X - (v60.Y - v18.Y) / Math.Tan(sig / 2), v60.Y);
                Vector2 v58 = new Vector2(-v57.X, v57.Y);
                Vector2 v59 = new Vector2(-v18.X, v18.Y);
                Vector2 v61 = new Vector2(-v60.X, v60.Y);
                double x62 = bd2 / 2 - rcf;
                if (v40.Y > v8.Y)
                {
                    x62 = v6.X - Math.Sqrt(rcf * rcf - (v40.Y - v8.Y) * (v40.Y - v8.Y));
                }
                Vector2 v62 = new Vector2(x62, v40.Y);
                //线段
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                Vector2[] Line3 = { v3, v4 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v4, v5 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v5, v6 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v6, v37 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                Vector2[] Line11 = { v37, v38 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
                Vector2[] Line12 = { v38, v39 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line13 = { v10, v11 };
                fun.drawPlinetype(dxf, Line13, 0.15, refin, Linetype.Dashed);
                Vector2[] Line16 = { v11, v16 };
                fun.drawPlinetype(dxf, Line16, 0.15, refin, Linetype.Dashed);
                Vector2[] Line19 = { v16, v17 };
                fun.drawPlinetype(dxf, Line19, 0.15, refin, Linetype.Dashed);
                Vector2[] Line20 = { v17, v18 };
                fun.drawPlinetype(dxf, Line20, 0.15, refin, Linetype.Dashed);
                Vector2[] Line21 = { v62, v40 };
                fun.drawBLine(dxf, Line21, 0.3, contour);
                Vector2[] Line22 = { v18, v57 };
                fun.drawPlinetype(dxf, Line22, 0.15, refin, Linetype.Dashed);
                Vector2[] Line23 = { v58, v59 };
                fun.drawPlinetype(dxf, Line23, 0.15, refin, Linetype.Dashed);
                Vector2[] Line24 = { v19, v59 };
                fun.drawPlinetype(dxf, Line24, 0.15, refin, Linetype.Dashed);
                Vector2[] Line25 = { v19, v20 };
                fun.drawPlinetype(dxf, Line25, 0.15, refin, Linetype.Dashed);
                Vector2[] Line26 = { v20, v25 };
                fun.drawPlinetype(dxf, Line26, 0.15, refin, Linetype.Dashed);
                Vector2[] Line31 = { v25, v26 };
                fun.drawPlinetype(dxf, Line31, 0.15, refin, Linetype.Dashed);
                Vector2[] Line32 = { v27, v42 };
                fun.drawBLine(dxf, Line32, 0.3, contour);
                Vector2[] Line37 = { v42, v41 };
                fun.drawBLine(dxf, Line37, 0.3, contour);
                Vector2[] Line38 = { v41, v40 };
                fun.drawBLine(dxf, Line38, 0.3, contour);
                Vector2[] Line39 = { v27, v28 };
                fun.drawBLine(dxf, Line39, 0.3, contour);
                Vector2[] Line40 = { v28, v29 };
                fun.drawBLine(dxf, Line40, 0.3, contour);
                Vector2[] Line41 = { v29, v30 };
                fun.drawBLine(dxf, Line41, 0.3, contour);
                Vector2[] Line42 = { v30, v31 };
                fun.drawBLine(dxf, Line42, 0.3, contour);
                Vector2[] Line43 = { v31, v32 };
                fun.drawBLine(dxf, Line43, 0.3, contour);
                Vector2[] Line44 = { v32, v1 };
                fun.drawBLine(dxf, Line44, 0.3, contour);
                Vector2[] Line45 = { v31, v2 };
                fun.drawBLine(dxf, Line45, 0.3, contour);
                Vector2[] Line46 = { v30, v3 };
                fun.drawBLine(dxf, Line46, 0.3, contour);
                Vector2[] Line47 = { v27, v6 };
                fun.drawBLine(dxf, Line47, 0.3, contour);
                Vector2[] Line52 = { v41, v55 };
                fun.drawBLine(dxf, Line52, 0.3, contour);
                Vector2[] Line53 = { v47, v48 };
                fun.drawPlinetype(dxf, Line53, 0.15, center, Linetype.Center);
                Vector2[] Line56 = { v8, v9 };
                fun.drawBLine(dxf, Line56, 0.3, contour);
                Vector2[] Line57 = { v42, v56 };
                fun.drawBLine(dxf, Line57, 0.3, contour);
                LwPolyline Arc1 = new LwPolyline();
                Arc1.Vertexes.Add(new LwPolylineVertex(v7));
                Arc1.Vertexes.Add(new LwPolylineVertex(v8));
                Arc1.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * 2 * Math.Cos(pi / 4);
                fun.PolyFill(dxf, Arc1, 0.3, contour);
                Arc Arc2 = new Arc(new Vector2(v7.X, v8.Y), rcf, 90, 180);
                Vector2[] Line58 = { v39, v60 };
                fun.drawBLine(dxf, Line58, 0.3, contour);
                Vector2[] Line59 = { v40, v61 };
                fun.drawBLine(dxf, Line59, 0.3, contour);
                Vector2[] Line60 = { v60, v61 };
                fun.drawBLine(dxf, Line60, 0.3, contour);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 1.0;
                double offset = 10;
                //线段尺寸标注
                //尺寸1
                Angular2LineDimension angdim1 = new Angular2LineDimension(new Line(v59, v19), new Line(v18, v17), v17.X / Math.Sin(sig / 2) * Math.Cos(sig / 2), dimensionStyle);
                angdim1.UserText = "SIG = " + Math.Round(sig / (pi / 180), 2) + "°";
                dxf.AddEntity(angdim1);
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(v17, v19), -pl - offset, 0, dimensionStyle);
                dim2.UserText = "DC_1 = " + Math.Round(dc1 / scale, 2);
                dxf.AddEntity(dim2);
                //尺寸5
                LinearDimension dim5 = new LinearDimension(new Line(v59, v19), -offset - v4.X + (v17.X + v18.X) / 2, 270, dimensionStyle);
                dim5.UserText = "PL = " + Math.Round(pl / scale, 2);
                dxf.AddEntity(dim5);
                //尺寸6
                LinearDimension dim6 = new LinearDimension(new Line(v1, v3), offset + 0.25 + v4.X - v3.X, 270, dimensionStyle);
                dim6.UserText = "LS = " + Math.Round(ls / scale, 2);
                dxf.AddEntity(dim6);
                //尺寸7
                LinearDimension dim7 = new LinearDimension(new Line(v41, v19), -offset - (v4.X - (v38.X + v17.X) / 2), 270, dimensionStyle);
                dim7.UserText = "SDL_1 = " + Math.Round(sdl1 / scale, 2);
                dxf.AddEntity(dim7);
                //尺寸9
                LinearDimension dim9 = new LinearDimension(new Line(v18, v1), offset * 3 + v4.X - (v1.X + v18.X) / 2 + 0.25, 270, dimensionStyle);
                dim9.UserText = "OAL = " + Math.Round(oal / scale, 2);
                dxf.AddEntity(dim9);
                //尺寸10
                LinearDimension dim10 = new LinearDimension(new Line(v31, v2), offset + 0.5, 0, dimensionStyle);
                dim10.UserText = "DCONMS = " + Math.Round(dconms / scale, 2);
                dxf.AddEntity(dim10);
                //尺寸11
                if (sta2 != pi)
                {
                    Angular2LineDimension angdim11 = new Angular2LineDimension(new Line(v41, v42), new Line(v38, v37), v37.X / Math.Sin(sta2 / 2) * Math.Cos(sta2 / 2) + offset, dimensionStyle);
                    angdim11.UserText = "STA_2 = " + Math.Round(sta2 / (pi / 180), 2) + "°";
                    dxf.AddEntity(angdim11);
                }
                if (sta2 == pi)
                {
                    Angular2LineDimension angdim11 = new Angular2LineDimension(new Line(v41, new Vector2(v42.X, v42.Y + 0.1)), new Line(v38, new Vector2(v37.X, v37.Y + 0.1)), v37.X / Math.Sin(sta2 / 2) * Math.Cos(sta2 / 2) + offset, dimensionStyle);
                    angdim11.UserText = "STA_2 = " + Math.Round(sta2 / (pi / 180), 2) + "°";
                    dxf.AddEntity(angdim11);
                }
                //尺寸13
                LinearDimension dim13 = new LinearDimension(new Line(v11, v25), -v11.Y + v18.Y - offset * 2, 0, dimensionStyle);
                dim13.UserText = "DC_2 = " + Math.Round(dc2 / scale, 2);
                dxf.AddEntity(dim13);
                //尺寸16
                LinearDimension dim16 = new LinearDimension(new Line(v4, v5), offset, 270, dimensionStyle);
                dim16.UserText = "FLGT = " + Math.Round(flgt / scale, 2);
                dxf.AddEntity(dim16);
                //尺寸17
                LinearDimension dim17 = new LinearDimension(new Line(v7, v18), offset - (v7.X + v18.X) / 2 + v4.X, 270, dimensionStyle);
                dim17.UserText = "LCF = " + Math.Round(lcf / scale, 2);
                dxf.AddEntity(dim17);
                //尺寸18
                LinearDimension dim18 = new LinearDimension(new Line(v4, v18), offset * 2 + (v4.X - v18.X) / 2, 270, dimensionStyle);
                dim18.UserText = "LPR = " + Math.Round(lpr / scale, 2);
                dxf.AddEntity(dim18);
                //尺寸19
                LinearDimension dim19 = new LinearDimension(new Line(v29, v4), -flgt / 2, 0, dimensionStyle);
                dim19.UserText = "DF = " + Math.Round(df / scale, 2);
                dxf.AddEntity(dim19);
                //尺寸20
                LinearDimension dim20 = new LinearDimension(new Line(v27, v6), -(v27.Y - v42.Y) / 2, 0, dimensionStyle);
                dim20.UserText = "BD_2 = " + Math.Round(bd2 / scale, 2);
                dxf.AddEntity(dim20);
                //尺寸23
                LinearDimension dim23 = new LinearDimension(new Line(v41, v38), -(v41.Y - v40.Y) / 2, 0, dimensionStyle);
                dim23.UserText = "BD_1 = " + Math.Round(bd1 / scale, 2);
                dxf.AddEntity(dim23);
                //尺寸24
                RadialDimension dimrad24 = new RadialDimension(Arc2, 135, 0, dimensionStyle);//DimensionStyle.Default);
                dimrad24.UserText = "RCF = " + Math.Round(rcf / scale, 2);
                dxf.AddEntity(dimrad24);
            }
            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(-148.5, 200 - oal / 2));
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            //定义格式，根据路径导出

            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);


            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
        public static void TrepanningDrill(Dictionary<string, Object> data) //套料钻
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);
            //作图
            //参数
            string path = Convert.ToString(data["path"]);
            double soal = Convert.ToDouble(data["oal"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0 && soal < 67)
            {
                scale = 4.0;
            }
            else if (scale == 0 && soal < 90)
            {
                scale = 3.0;
            }
            else if (scale == 0 && soal < 134)
            {
                scale = 2.0;
            }
            else if (scale == 0 && soal < 178)
            {
                scale = 1.5;
            }
            else if (scale == 0 && soal < 268)
            {
                scale = 1.0;
            }
            else if (scale == 0 && soal < 357)
            {
                scale = 0.75;
            }
            else if (scale == 0)
            {
                scale = 0.5;
            }
            double pi = Math.PI;
            double bdx = Convert.ToDouble(data["bdx"]) * scale;
            double dcx = Convert.ToDouble(data["dcx"]) * scale;
            double dconms = Convert.ToDouble(data["dconms"]) * scale;
            double bdn = Convert.ToDouble(data["bdn"]) * scale;
            double dcn = Convert.ToDouble(data["dcn"]) * scale;
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double ls = Convert.ToDouble(data["ls"]) * scale;
            double df = Convert.ToDouble(data["df"]) * scale;
            double flgt = Convert.ToDouble(data["flgt"]) * scale;
            double lcf = Convert.ToDouble(data["lcf"]) * scale;
            double rcf = Convert.ToDouble(data["rcf"]) * scale;
            double sig = Convert.ToDouble(data["sig"]) * pi / 180;
            double isframe = Convert.ToDouble(data["isframe"]);
            double pl = Convert.ToDouble(data["pl"]) * scale;
            //double lu = lcf - rcf;
            double lpr = oal - ls;
            double lb = Convert.ToDouble(data["lb"]) * scale;
            //坐标
            //主视图
            Vector2 v1 = new Vector2(dconms / 2 - 0.5, 0);
            Vector2 v2 = new Vector2(v1.X + 0.5, -0.5);
            Vector2 v3 = new Vector2(v2.X, -ls);
            Vector2 v4 = new Vector2(df / 2, v3.Y);
            Vector2 v5 = new Vector2(v4.X, v4.Y - flgt);
            Vector2 v6 = new Vector2(bdx / 2, v5.Y);
            Vector2 v7 = new Vector2(v6.X, -oal + pl);
            Vector2 v8 = new Vector2(v6.X, -oal + lcf);
            Vector2 v9 = new Vector2(v8.X-rcf, v8.Y-rcf);
            Vector2 v10 = new Vector2(v9.X, -oal+pl+lb);
            Vector2 v11 = new Vector2(v10.X, v7.Y);
            Vector2 v12 = new Vector2(Math.Sqrt(bdn*bdn/4-(bdx/2 - rcf) * (bdx / 2 - rcf)), -oal+pl);
            Vector2 v13 = new Vector2(0, -oal + lcf - rcf+v12.X);
            Vector2 v14 = new Vector2(0, v10.Y);
            Vector2 v15 = new Vector2(0, -oal+lcf);
            Vector2 v16 = new Vector2(-Math.Sqrt(bdx*rcf-rcf*rcf), -oal+lcf-rcf);
            Vector2 v35 = new Vector2(v16.X+rcf, -oal + lcf);
            Vector2 v17 = new Vector2(v16.X, v7.Y);
            Vector2 v18 = new Vector2(-v12.X, v12.Y);
            Vector2 v19 = new Vector2(-v12.X, v16.Y);
            Vector2 v20 = new Vector2(-v19.X, v19.Y);
            Vector2 v21 = new Vector2(-v7.X, v7.Y);
            Vector2 v22 = new Vector2(-v6.X, v6.Y);
            Vector2 v36 = new Vector2(-v5.X, v5.Y);
            Vector2 v23 = new Vector2(-v4.X, v4.Y);
            Vector2 v24 = new Vector2(-v3.X, v3.Y);
            Vector2 v25 = new Vector2(-v2.X, v2.Y);
            Vector2 v26 = new Vector2(-v1.X, v1.Y);
            Vector2 v27 = new Vector2(-dcx/2, v21.Y);
            Vector2 v28 = new Vector2(v27.X+pl*Math.Tan(sig/2), v27.Y-pl);
            Vector2 v29 = new Vector2(-v28.X, v28.Y);
            Vector2 v30 = new Vector2(-v27.X, v27.Y);
            Vector2 v31 = new Vector2(0, 2);
            Vector2 v32 = new Vector2(0, -oal - 2);
            Vector2 v33 = new Vector2(bdn/2, v10.Y);
            Vector2 v34 = new Vector2(v33.X, v30.Y);
            Vector2 v38 = new Vector2(-dcn/2, v27.Y);
            Vector2 v37 = new Vector2(v38.X - pl * Math.Tan(sig / 2), v28.Y);
            Vector2 v39 = new Vector2(-v38.X, v38.Y);
            Vector2 v40 = new Vector2(-v37.X, v37.Y);
            Vector2 v41 = new Vector2(Math.Sqrt(rcf * rcf - (v33.Y-v9.Y) * (v33.Y - v9.Y)), v33.Y);
            Vector2 v42 = new Vector2(-Math.Sqrt((v13.Y-v19.Y) * (v13.Y - v19.Y) - (v33.Y - v19.Y) * (v33.Y - v19.Y)), v33.Y);
            Vector2 v43 = new Vector2(-v42.X, v42.Y);
            Vector2 v44 = new Vector2(v33.X, Math.Sqrt(rcf * rcf - (v8.X - v33.X) * (v8.X - v33.X)) + v9.Y);
            double r = Math.Sqrt((v8.X - v33.X) * (v8.X - v33.X) + (v33.Y - v9.Y) * (v33.Y - v9.Y));
            //线段
            //主视图
            if ((bdn+rcf*2)<=bdx)
            {
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                Vector2[] Line3 = { v3, v4 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v4, v5 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v5, v6 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v6, v7 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                LwPolyline Arc7 = new LwPolyline();
                Arc7.Vertexes.Add(new LwPolylineVertex(v8));
                Arc7.Vertexes.Add(new LwPolylineVertex(v9));
                Arc7.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * Math.Cos(pi / 4) * 2;
                fun.PolyFill(dxf, Arc7, 0.3, contour);
                Vector2[] Line8 = { v9, v11 };
                fun.drawBLine(dxf, Line8, 0.3, contour);
                Vector2[] Line9 = { v14, v33 };
                fun.drawBLine(dxf, Line9, 0.3, contour);
                Vector2[] Line10 = { v33, v34 };
                fun.drawBLine(dxf, Line10, 0.3, contour);
                Vector2[] Line13 = { v27, v28 };
                fun.drawPlinetype(dxf, Line13, 0.15, refin, Linetype.Dashed);
                Vector2[] Line14 = { v28, v37 };
                fun.drawPlinetype(dxf, Line14, 0.15, refin, Linetype.Dashed);
                Vector2[] Line15 = { v29, v30 };
                fun.drawPlinetype(dxf, Line15, 0.15, refin, Linetype.Dashed);
                Vector2[] Line16 = { v30, v7 };
                fun.drawPlinetype(dxf, Line16, 0.15, refin, Linetype.Dashed);
                Vector2[] Line17 = { v21, v27 };
                fun.drawPlinetype(dxf, Line17, 0.15, refin, Linetype.Dashed);
                Vector2[] Line19 = { v17, v16 };
                fun.drawBLine(dxf, Line19, 0.3, contour);
                LwPolyline Arc17 = new LwPolyline();
                Arc17.Vertexes.Add(new LwPolylineVertex(v35));
                Arc17.Vertexes.Add(new LwPolylineVertex(v16));
                Arc17.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * Math.Cos(pi / 4) * 2;
                fun.PolyFill(dxf, Arc17, 0.3, contour);
                Vector2[] Line20 = { v15, v35 };
                fun.drawBLine(dxf, Line20, 0.3, contour);
                Vector2[] Line21 = { v21, v22 };
                fun.drawBLine(dxf, Line21, 0.3, contour);
                Vector2[] Line22 = { v22, v36 };
                fun.drawBLine(dxf, Line22, 0.3, contour);
                Vector2[] Line23 = { v36, v23 };
                fun.drawBLine(dxf, Line23, 0.3, contour);
                Vector2[] Line24 = { v23, v24 };
                fun.drawBLine(dxf, Line24, 0.3, contour);
                Vector2[] Line25 = { v24, v25 };
                fun.drawBLine(dxf, Line25, 0.3, contour);
                Vector2[] Line26 = { v25, v26 };
                fun.drawBLine(dxf, Line26, 0.3, contour);
                Vector2[] Line27 = { v26, v1 };
                fun.drawBLine(dxf, Line27, 0.3, contour);
                Vector2[] Line28 = { v25, new Vector2(0, v25.Y) };
                fun.drawBLine(dxf, Line28, 0.3, contour);
                Vector2[] Line29 = { v24, new Vector2(0, v24.Y) };
                fun.drawBLine(dxf, Line29, 0.3, contour);
                Vector2[] Line30 = { v36, new Vector2(0, v36.Y) };
                fun.drawBLine(dxf, Line30, 0.3, contour);
                Vector2[] Line32 = { v31, v32 };
                fun.drawPlinetype(dxf, Line32, 0.15, center, Linetype.Center);
                Arc arc33 = new Arc(new Vector2(v8.X, v9.Y), rcf, 90, 180);
                Vector2[] Line34 = { v37, v38 };
                fun.drawPlinetype(dxf, Line34, 0.15, refin, Linetype.Dashed);
                Vector2[] Line35 = { v39, v40 };
                fun.drawPlinetype(dxf, Line35, 0.15, refin, Linetype.Dashed);
                Vector2[] Line36 = { v29, v40 };
                fun.drawPlinetype(dxf, Line36, 0.15, refin, Linetype.Dashed);
                Vector2[] Line31 = { v21, v7 };
                fun.drawBLine(dxf, Line31, 0.3, contour);
                //填充
                LwPolyline hatchpoly1 = new LwPolyline();
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v6));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v8));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v9));
                hatchpoly1.Vertexes[1].Bulge = Math.Tan(pi / 8);
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v11));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v34));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v33));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v14));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(new Vector2(0,0)));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v1));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v2));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v3));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v4));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v5));
                hatchpoly1.IsClosed = true;
                String[] htype1 = new String[100];
                Line[] hline1 = new Line[100];
                Arc[] harc1 = new Arc[100];
                int hnumst1 = hatchpoly1.Explode().Count;  //记录爆炸后，线段有多少
                for (int i = 0; i < hnumst1; i++)
                {
                    htype1[i] = hatchpoly1.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                    if (htype1[i] == "Line")
                    {
                        hline1[i] = (Line)hatchpoly1.Explode()[i];
                    }
                    if (htype1[i] == "Arc")
                    {
                        harc1[i] = (Arc)hatchpoly1.Explode()[i];
                    }
                }
                fun.hatchsub1(dxf, htype1, hnumst1, 45, dconms/2, hline1, harc1, hatching);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 1.0;
                double offset = 10;
                //线段尺寸标注
                //尺寸1
                LinearDimension dim1 = new LinearDimension(new Line(v4, v5), offset+v30.X-v4.X, 270, dimensionStyle);
                dim1.UserText = "FLGT = " + Math.Round(flgt / scale, 2);
                dxf.AddEntity(dim1);
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(v38, v39), -offset - pl, 0, dimensionStyle);
                dim2.UserText = "DCN = " + Math.Round(dcn / scale, 2);
                dxf.AddEntity(dim2);
                //尺寸4
                LinearDimension dim4 = new LinearDimension(new Line(v1, v3), offset * 3 +v30.X - (v3.X + v1.X) / 2, 270, dimensionStyle);
                dim4.UserText = "LS = " + Math.Round(ls / scale, 2);
                dxf.AddEntity(dim4);
                //尺寸5
                LinearDimension dim5 = new LinearDimension(new Line(v29, v1), offset * 4 + v30.X - (v29.X+v1.X) / 2, 270, dimensionStyle);
                dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                dxf.AddEntity(dim5);
                //尺寸6
                LinearDimension dim6 = new LinearDimension(new Line(v25, v2), offset + 0.5, 0, dimensionStyle);
                dim6.UserText = "DCONMS = " + Math.Round(dconms / scale, 2);
                dxf.AddEntity(dim6);
                //尺寸7
                LinearDimension dim7 = new LinearDimension(new Line(v23, v4), offset * 2 + ls, 0, dimensionStyle);
                dim7.UserText = "DF = " + Math.Round(df / scale, 2);
                dxf.AddEntity(dim7);
                //尺寸8
                LinearDimension dim8 = new LinearDimension(new Line(v22, v6), offset * 3 +ls+flgt, 0, dimensionStyle);
                dim8.UserText = "BDX = " + Math.Round(bdx / scale, 2);
                dxf.AddEntity(dim8);
                //尺寸9
                LinearDimension dim9 = new LinearDimension(new Line(v4, v29), offset * 3 + v30.X-(v4.X+v29.X)/2, 270, dimensionStyle);
                dim9.UserText = "LPR = " + Math.Round(lpr / scale, 2);
                dxf.AddEntity(dim9);
                //尺寸10
                LinearDimension dim10 = new LinearDimension(new Line(v33, v34), offset + v30.X - v34.X, 270, dimensionStyle);
                dim10.UserText = "LB = " + Math.Round(lb / scale, 2);
                dxf.AddEntity(dim10);
                //尺寸11
                LinearDimension dim11 = new LinearDimension(new Line(v8, v29), offset * 2 + v30.X - (v8.X+v29.X)/2, 270, dimensionStyle);
                dim11.UserText = "LCF = " + Math.Round(lcf / scale, 2);
                dxf.AddEntity(dim11);
                //尺寸12
                LinearDimension dim12 = new LinearDimension(new Line(v29, v30), offset + (v30.X-v29.X) / 2, 270, dimensionStyle);
                dim12.UserText = "PL = " + Math.Round(pl / scale, 2);
                dxf.AddEntity(dim12);
                //尺寸13
                RadialDimension dimrad13 = new RadialDimension(arc33, 135, -rcf, dimensionStyle);//DimensionStyle.Default);
                dimrad13.UserText = "RCF = " + Math.Round(rcf / scale, 2);
                dxf.AddEntity(dimrad13);
                //尺寸14
                Angular2LineDimension angdim14 = new Angular2LineDimension(new Line(v28,v27), new Line(v29,v30), v30.X/Math.Tan(sig/2)+offset, dimensionStyle);
                angdim14.UserText = "SIG = " + Math.Round(sig / pi * 180, 2) + "°";
                dxf.AddEntity(angdim14);
                //尺寸15
                LinearDimension dim15 = new LinearDimension(new Line(v34, new Vector2(-v34.X,v34.Y)), -offset*2 - pl, 0, dimensionStyle);
                dim15.UserText = "BDN = " + Math.Round(bdn / scale, 2);
                dxf.AddEntity(dim15);
                //尺寸16
                LinearDimension dim16 = new LinearDimension(new Line(v27, v30), -offset*3 - pl, 0, dimensionStyle);
                dim16.UserText = "DCX = " + Math.Round(dcx / scale, 2);
                dxf.AddEntity(dim16);
            }
            if ((bdn + rcf * 2) > bdx&&v33.Y<=v9.Y)
            {
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                Vector2[] Line3 = { v3, v4 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v4, v5 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v5, v6 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v6, v7 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                LwPolyline Arc7 = new LwPolyline();
                Arc7.Vertexes.Add(new LwPolylineVertex(v8));
                Arc7.Vertexes.Add(new LwPolylineVertex(v9));
                Arc7.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * Math.Cos(pi / 4) * 2;
                fun.PolyFill(dxf, Arc7, 0.3, contour);
                Vector2[] Line8 = { v9, v10 };
                fun.drawBLine(dxf, Line8, 0.3, contour);
                Vector2[] Line9 = { new Vector2(v19.X, v33.Y), v33 };
                fun.drawBLine(dxf, Line9, 0.3, contour);
                Vector2[] Line10 = { v33, v34 };
                fun.drawBLine(dxf, Line10, 0.3, contour);
                /*Vector2[] Line11 = { v15, new Vector2(v15.X, v12.Y) };
                fun.drawBLine(dxf, Line11, 0.3, contour);*/
                Vector2[] Line12 = { v12, new Vector2(v12.X, v33.Y) };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                /*LwPolyline Arc8 = new LwPolyline();
                Arc8.Vertexes.Add(new LwPolylineVertex(v20));
                Arc8.Vertexes.Add(new LwPolylineVertex(v13));
                Arc8.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * Math.Cos(pi / 4) * 2;
                fun.PolyFill(dxf, Arc8, 0.3, contour);*/
                Vector2[] Line13 = { v27, v28 };
                fun.drawPlinetype(dxf, Line13, 0.15, refin, Linetype.Dashed);
                Vector2[] Line14 = { v28, v37 };
                fun.drawPlinetype(dxf, Line14, 0.15, refin, Linetype.Dashed);
                Vector2[] Line15 = { v37, v38 };
                fun.drawPlinetype(dxf, Line15, 0.15, refin, Linetype.Dashed);
                Vector2[] Line16 = { v39, v40 };
                fun.drawPlinetype(dxf, Line16, 0.15, refin, Linetype.Dashed);
                Vector2[] Line17 = { v21, v27 };
                fun.drawPlinetype(dxf, Line17, 0.15, refin, Linetype.Dashed);
                Vector2[] Line33 = { v40, v29 };
                fun.drawPlinetype(dxf, Line33, 0.15, refin, Linetype.Dashed);
                Vector2[] Line34 = { v29, v30 };
                fun.drawPlinetype(dxf, Line34, 0.15, refin, Linetype.Dashed);
                Vector2[] Line35 = { v30, v7 };
                fun.drawPlinetype(dxf, Line35, 0.15, refin, Linetype.Dashed);
                /*LwPolyline Arc16 = new LwPolyline();
                Arc16.Vertexes.Add(new LwPolylineVertex(v13));
                Arc16.Vertexes.Add(new LwPolylineVertex(v19));
                Arc16.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * Math.Cos(pi / 4) * 2;
                fun.PolyFill(dxf, Arc16, 0.3, contour);*/
                Vector2[] Line18 = { v18, new Vector2(v18.X, v33.Y) };
                fun.drawBLine(dxf, Line18, 0.3, contour);
                Vector2[] Line19 = { v17, v16 };
                fun.drawBLine(dxf, Line19, 0.3, contour);
                LwPolyline Arc17 = new LwPolyline();
                Arc17.Vertexes.Add(new LwPolylineVertex(v35));
                Arc17.Vertexes.Add(new LwPolylineVertex(v16));
                Arc17.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * Math.Cos(pi / 4) * 2;
                fun.PolyFill(dxf, Arc17, 0.3, contour);
                Vector2[] Line20 = { v15, v35 };
                fun.drawBLine(dxf, Line20, 0.3, contour);
                Vector2[] Line21 = { v21, v22 };
                fun.drawBLine(dxf, Line21, 0.3, contour);
                Vector2[] Line22 = { v22, v36 };
                fun.drawBLine(dxf, Line22, 0.3, contour);
                Vector2[] Line23 = { v36, v23 };
                fun.drawBLine(dxf, Line23, 0.3, contour);
                Vector2[] Line24 = { v23, v24 };
                fun.drawBLine(dxf, Line24, 0.3, contour);
                Vector2[] Line25 = { v24, v25 };
                fun.drawBLine(dxf, Line25, 0.3, contour);
                Vector2[] Line26 = { v25, v26 };
                fun.drawBLine(dxf, Line26, 0.3, contour);
                Vector2[] Line27 = { v26, v1 };
                fun.drawBLine(dxf, Line27, 0.3, contour);
                Vector2[] Line28 = { v25, new Vector2(0, v2.Y) };
                fun.drawBLine(dxf, Line28, 0.3, contour);
                Vector2[] Line29 = { v24, new Vector2(0, v3.Y) };
                fun.drawBLine(dxf, Line29, 0.3, contour);
                Vector2[] Line30 = { v36, new Vector2(0, v5.Y) };
                fun.drawBLine(dxf, Line30, 0.3, contour);
                Vector2[] Line31 = { v21, new Vector2(0, v18.Y) };
                fun.drawBLine(dxf, Line31, 0.3, contour);
                Vector2[] Line32 = { v31, v32 };
                fun.drawPlinetype(dxf, Line32, 0.15, center, Linetype.Center);
                Arc arc33 = new Arc(new Vector2(v8.X, v9.Y), rcf, 90, 180);
                Vector2[] Line36 = { v12, v7 };
                fun.drawBLine(dxf, Line36, 0.3, contour);
                Vector2[] Line37 = { v38, v18 };
                fun.drawPlinetype(dxf, Line37, 0.15, refin, Linetype.Dashed);
                Vector2[] Line38 = { v39, v12 };
                fun.drawPlinetype(dxf, Line38, 0.15, refin, Linetype.Dashed);
                //填充
                LwPolyline hatchpoly1 = new LwPolyline();
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v6));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v8));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v9));
                hatchpoly1.Vertexes[1].Bulge = Math.Tan(pi / 8);
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v10));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v14));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(new Vector2(0, 0)));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v1));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v2));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v3));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v4));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v5));
                hatchpoly1.IsClosed = true;
                String[] htype1 = new String[100];
                Line[] hline1 = new Line[100];
                Arc[] harc1 = new Arc[100];
                int hnumst1 = hatchpoly1.Explode().Count;  //记录爆炸后，线段有多少
                for (int i = 0; i < hnumst1; i++)
                {
                    htype1[i] = hatchpoly1.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                    if (htype1[i] == "Line")
                    {
                        hline1[i] = (Line)hatchpoly1.Explode()[i];
                    }
                    if (htype1[i] == "Arc")
                    {
                        harc1[i] = (Arc)hatchpoly1.Explode()[i];
                    }
                }
                fun.hatchsub1(dxf, htype1, hnumst1, 45, dconms / 2, hline1, harc1, hatching);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 1.0;
                double offset = 10;
                //线段尺寸标注
                //尺寸1
                LinearDimension dim1 = new LinearDimension(new Line(v4, v5), offset + v30.X - v4.X, 270, dimensionStyle);
                dim1.UserText = "FLGT = " + Math.Round(flgt / scale, 2);
                dxf.AddEntity(dim1);
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(v38, v39), -offset - pl, 0, dimensionStyle);
                dim2.UserText = "DCN = " + Math.Round(dcn / scale, 2);
                dxf.AddEntity(dim2);
                //尺寸4
                LinearDimension dim4 = new LinearDimension(new Line(v1, v3), offset * 3 + v30.X - (v3.X + v1.X) / 2, 270, dimensionStyle);
                dim4.UserText = "LS = " + Math.Round(ls / scale, 2);
                dxf.AddEntity(dim4);
                //尺寸5
                LinearDimension dim5 = new LinearDimension(new Line(v29, v1), offset * 4 + v30.X - (v29.X + v1.X) / 2, 270, dimensionStyle);
                dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                dxf.AddEntity(dim5);
                //尺寸6
                LinearDimension dim6 = new LinearDimension(new Line(v25, v2), offset + 0.5, 0, dimensionStyle);
                dim6.UserText = "DCONMS = " + Math.Round(dconms / scale, 2);
                dxf.AddEntity(dim6);
                //尺寸7
                LinearDimension dim7 = new LinearDimension(new Line(v23, v4), offset * 2 + ls, 0, dimensionStyle);
                dim7.UserText = "DF = " + Math.Round(df / scale, 2);
                dxf.AddEntity(dim7);
                //尺寸8
                LinearDimension dim8 = new LinearDimension(new Line(v22, v6), offset * 3 + ls + flgt, 0, dimensionStyle);
                dim8.UserText = "BDX = " + Math.Round(bdx / scale, 2);
                dxf.AddEntity(dim8);
                //尺寸9
                LinearDimension dim9 = new LinearDimension(new Line(v4, v29), offset * 3 + v30.X - (v4.X + v29.X) / 2, 270, dimensionStyle);
                dim9.UserText = "LPR = " + Math.Round(lpr / scale, 2);
                dxf.AddEntity(dim9);
                //尺寸10
                LinearDimension dim10 = new LinearDimension(new Line(v33, v34), offset + v30.X - v34.X, 270, dimensionStyle);
                dim10.UserText = "LB = " + Math.Round(lb / scale, 2);
                dxf.AddEntity(dim10);
                //尺寸11
                LinearDimension dim11 = new LinearDimension(new Line(v8, v29), offset * 2 + v30.X - (v8.X + v29.X) / 2, 270, dimensionStyle);
                dim11.UserText = "LCF = " + Math.Round(lcf / scale, 2);
                dxf.AddEntity(dim11);
                //尺寸12
                LinearDimension dim12 = new LinearDimension(new Line(v29, v30), offset + (v30.X - v29.X) / 2, 270, dimensionStyle);
                dim12.UserText = "PL = " + Math.Round(pl / scale, 2);
                dxf.AddEntity(dim12);
                //尺寸13
                RadialDimension dimrad13 = new RadialDimension(arc33, 135, -rcf, dimensionStyle);//DimensionStyle.Default);
                dimrad13.UserText = "RCF = " + Math.Round(rcf / scale, 2);
                dxf.AddEntity(dimrad13);
                //尺寸14
                Angular2LineDimension angdim14 = new Angular2LineDimension(new Line(v28, v27), new Line(v29, v30), v30.X / Math.Tan(sig / 2) + offset, dimensionStyle);
                angdim14.UserText = "SIG = " + Math.Round(sig / pi * 180, 2) + "°";
                dxf.AddEntity(angdim14);
                //尺寸15
                LinearDimension dim15 = new LinearDimension(new Line(v34, new Vector2(-v34.X, v34.Y)), -offset * 2 - pl, 0, dimensionStyle);
                dim15.UserText = "BDN = " + Math.Round(bdn / scale, 2);
                dxf.AddEntity(dim15);
                //尺寸16
                LinearDimension dim16 = new LinearDimension(new Line(v27, v30), -offset * 3 - pl, 0, dimensionStyle);
                dim16.UserText = "DCX = " + Math.Round(dcx / scale, 2);
                dxf.AddEntity(dim16);
            }
            if ((bdn + rcf * 2) > bdx && v33.Y > v9.Y&&r<=rcf)
            {
                double l = Math.Sqrt((v8.X - v41.X) * (v8.X - v41.X) + (v8.Y - v41.Y) * (v8.Y - v41.Y));
                double h = rcf - Math.Sqrt(rcf * rcf - l * l / 4);
                double l2 = Math.Sqrt((v42.X - v19.X) * (v42.X - v19.X) + (v42.Y - v19.Y) * (v42.Y - v19.Y));
                double h2 = v13.Y-v19.Y - Math.Sqrt((v13.Y - v19.Y) * (v13.Y - v19.Y) - l2 * l2 / 4);
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                Vector2[] Line3 = { v3, v4 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v4, v5 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v5, v6 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v6, v7 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                LwPolyline Arc7 = new LwPolyline();
                Arc7.Vertexes.Add(new LwPolylineVertex(v8));
                Arc7.Vertexes.Add(new LwPolylineVertex(v41));
                Arc7.Vertexes[0].Bulge = 2 * h / l;
                fun.PolyFill(dxf, Arc7, 0.3, contour);
                Vector2[] Line9 = { v42, v33 };
                fun.drawBLine(dxf, Line9, 0.3, contour);
                Vector2[] Line10 = { v33, v34 };
                fun.drawBLine(dxf, Line10, 0.3, contour);
                /*Vector2[] Line11 = { v15, new Vector2(v15.X, v12.Y) };
                fun.drawBLine(dxf, Line11, 0.3, contour);*/
                Vector2[] Line12 = { v12, v20 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line11 = { v43, v42 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
                    LwPolyline Arc16 = new LwPolyline();
                    Arc16.Vertexes.Add(new LwPolylineVertex(v42));
                    Arc16.Vertexes.Add(new LwPolylineVertex(v19));
                    Arc16.Vertexes[0].Bulge = 2 * h2 / l2;
                    fun.PolyFill(dxf, Arc16, 0.3, contour);
                    LwPolyline Arc8 = new LwPolyline();
                    Arc8.Vertexes.Add(new LwPolylineVertex(v20));
                    Arc8.Vertexes.Add(new LwPolylineVertex(v43));
                    Arc8.Vertexes[0].Bulge = 2 * h2 / l2;
                    fun.PolyFill(dxf, Arc8, 0.3, contour);
                Vector2[] Line8 = { v18, v19 };
                fun.drawBLine(dxf, Line8, 0.3, contour);
                Vector2[] Line13 = { v27, v28 };
                fun.drawPlinetype(dxf, Line13, 0.15, refin, Linetype.Dashed);
                Vector2[] Line14 = { v28, v37 };
                fun.drawPlinetype(dxf, Line14, 0.15, refin, Linetype.Dashed);
                Vector2[] Line15 = { v37, v38 };
                fun.drawPlinetype(dxf, Line15, 0.15, refin, Linetype.Dashed);
                Vector2[] Line16 = { v39, v40 };
                fun.drawPlinetype(dxf, Line16, 0.15, refin, Linetype.Dashed);
                Vector2[] Line17 = { v21, v27 };
                fun.drawPlinetype(dxf, Line17, 0.15, refin, Linetype.Dashed);
                Vector2[] Line33 = { v40, v29 };
                fun.drawPlinetype(dxf, Line33, 0.15, refin, Linetype.Dashed);
                Vector2[] Line34 = { v29, v30 };
                fun.drawPlinetype(dxf, Line34, 0.15, refin, Linetype.Dashed);
                Vector2[] Line35 = { v30, v7 };
                fun.drawPlinetype(dxf, Line35, 0.15, refin, Linetype.Dashed);
                Vector2[] Line19 = { v17, v16 };
                fun.drawBLine(dxf, Line19, 0.3, contour);
                LwPolyline Arc17 = new LwPolyline();
                Arc17.Vertexes.Add(new LwPolylineVertex(v35));
                Arc17.Vertexes.Add(new LwPolylineVertex(v16));
                Arc17.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * Math.Cos(pi / 4) * 2;
                fun.PolyFill(dxf, Arc17, 0.3, contour);
                Vector2[] Line20 = { v15, v35 };
                fun.drawBLine(dxf, Line20, 0.3, contour);
                Vector2[] Line21 = { v21, v22 };
                fun.drawBLine(dxf, Line21, 0.3, contour);
                Vector2[] Line22 = { v22, v36 };
                fun.drawBLine(dxf, Line22, 0.3, contour);
                Vector2[] Line23 = { v36, v23 };
                fun.drawBLine(dxf, Line23, 0.3, contour);
                Vector2[] Line24 = { v23, v24 };
                fun.drawBLine(dxf, Line24, 0.3, contour);
                Vector2[] Line25 = { v24, v25 };
                fun.drawBLine(dxf, Line25, 0.3, contour);
                Vector2[] Line26 = { v25, v26 };
                fun.drawBLine(dxf, Line26, 0.3, contour);
                Vector2[] Line27 = { v26, v1 };
                fun.drawBLine(dxf, Line27, 0.3, contour);
                Vector2[] Line28 = { v25, new Vector2(0, v2.Y) };
                fun.drawBLine(dxf, Line28, 0.3, contour);
                Vector2[] Line29 = { v24, new Vector2(0, v3.Y) };
                fun.drawBLine(dxf, Line29, 0.3, contour);
                Vector2[] Line30 = { v36, new Vector2(0, v5.Y) };
                fun.drawBLine(dxf, Line30, 0.3, contour);
                Vector2[] Line31 = { v21, new Vector2(0, v18.Y) };
                fun.drawBLine(dxf, Line31, 0.3, contour);
                Vector2[] Line32 = { v31, v32 };
                fun.drawPlinetype(dxf, Line32, 0.15, center, Linetype.Center);
                Arc arc33 = new Arc(new Vector2(v8.X, v9.Y), rcf, 90, 180);
                Vector2[] Line36 = { v12, v7 };
                fun.drawBLine(dxf, Line36, 0.3, contour);
                Vector2[] Line37 = { v38, v18 };
                fun.drawPlinetype(dxf, Line37, 0.15, refin, Linetype.Dashed);
                Vector2[] Line38 = { v39, v12 };
                fun.drawPlinetype(dxf, Line38, 0.15, refin, Linetype.Dashed);
                //填充
                LwPolyline hatchpoly1 = new LwPolyline();
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v6));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v8));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v41));
                hatchpoly1.Vertexes[1].Bulge = 2 * h / l;
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(new Vector2(0,v41.Y)));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(new Vector2(0, 0)));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v1));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v2));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v3));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v4));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v5));
                hatchpoly1.IsClosed = true;
                String[] htype1 = new String[100];
                Line[] hline1 = new Line[100];
                Arc[] harc1 = new Arc[100];
                int hnumst1 = hatchpoly1.Explode().Count;  //记录爆炸后，线段有多少
                for (int i = 0; i < hnumst1; i++)
                {
                    htype1[i] = hatchpoly1.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                    if (htype1[i] == "Line")
                    {
                        hline1[i] = (Line)hatchpoly1.Explode()[i];
                    }
                    if (htype1[i] == "Arc")
                    {
                        harc1[i] = (Arc)hatchpoly1.Explode()[i];
                    }
                }
                fun.hatchsub1(dxf, htype1, hnumst1, 30, dconms / 2, hline1, harc1, hatching);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 1.0;
                double offset = 10;
                //线段尺寸标注
                //尺寸1
                LinearDimension dim1 = new LinearDimension(new Line(v4, v5), offset + v30.X - v4.X, 270, dimensionStyle);
                dim1.UserText = "FLGT = " + Math.Round(flgt / scale, 2);
                dxf.AddEntity(dim1);
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(v38, v39), -offset - pl, 0, dimensionStyle);
                dim2.UserText = "DCN = " + Math.Round(dcn / scale, 2);
                dxf.AddEntity(dim2);
                //尺寸4
                LinearDimension dim4 = new LinearDimension(new Line(v1, v3), offset * 3 + v30.X - (v3.X + v1.X) / 2, 270, dimensionStyle);
                dim4.UserText = "LS = " + Math.Round(ls / scale, 2);
                dxf.AddEntity(dim4);
                //尺寸5
                LinearDimension dim5 = new LinearDimension(new Line(v29, v1), offset * 4 + v30.X - (v29.X + v1.X) / 2, 270, dimensionStyle);
                dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                dxf.AddEntity(dim5);
                //尺寸6
                LinearDimension dim6 = new LinearDimension(new Line(v25, v2), offset + 0.5, 0, dimensionStyle);
                dim6.UserText = "DCONMS = " + Math.Round(dconms / scale, 2);
                dxf.AddEntity(dim6);
                //尺寸7
                LinearDimension dim7 = new LinearDimension(new Line(v23, v4), offset * 2 + ls, 0, dimensionStyle);
                dim7.UserText = "DF = " + Math.Round(df / scale, 2);
                dxf.AddEntity(dim7);
                //尺寸8
                LinearDimension dim8 = new LinearDimension(new Line(v22, v6), offset * 3 + ls + flgt, 0, dimensionStyle);
                dim8.UserText = "BDX = " + Math.Round(bdx / scale, 2);
                dxf.AddEntity(dim8);
                //尺寸9
                LinearDimension dim9 = new LinearDimension(new Line(v4, v29), offset * 3 + v30.X - (v4.X + v29.X) / 2, 270, dimensionStyle);
                dim9.UserText = "LPR = " + Math.Round(lpr / scale, 2);
                dxf.AddEntity(dim9);
                //尺寸10
                LinearDimension dim10 = new LinearDimension(new Line(v33, v34), offset + v30.X - v34.X, 270, dimensionStyle);
                dim10.UserText = "LB = " + Math.Round(lb / scale, 2);
                dxf.AddEntity(dim10);
                //尺寸11
                LinearDimension dim11 = new LinearDimension(new Line(v8, v29), offset * 2 + v30.X - (v8.X + v29.X) / 2, 270, dimensionStyle);
                dim11.UserText = "LCF = " + Math.Round(lcf / scale, 2);
                dxf.AddEntity(dim11);
                //尺寸12
                LinearDimension dim12 = new LinearDimension(new Line(v29, v30), offset + (v30.X - v29.X) / 2, 270, dimensionStyle);
                dim12.UserText = "PL = " + Math.Round(pl / scale, 2);
                dxf.AddEntity(dim12);
                //尺寸13
                RadialDimension dimrad13 = new RadialDimension(arc33, 135, -rcf, dimensionStyle);//DimensionStyle.Default);
                dimrad13.UserText = "RCF = " + Math.Round(rcf / scale, 2);
                dxf.AddEntity(dimrad13);
                //尺寸14
                Angular2LineDimension angdim14 = new Angular2LineDimension(new Line(v28, v27), new Line(v29, v30), v30.X / Math.Tan(sig / 2) + offset, dimensionStyle);
                angdim14.UserText = "SIG = " + Math.Round(sig / pi * 180, 2) + "°";
                dxf.AddEntity(angdim14);
                //尺寸15
                LinearDimension dim15 = new LinearDimension(new Line(v34, new Vector2(-v34.X, v34.Y)), -offset * 2 - pl, 0, dimensionStyle);
                dim15.UserText = "BDN = " + Math.Round(bdn / scale, 2);
                dxf.AddEntity(dim15);
                //尺寸16
                LinearDimension dim16 = new LinearDimension(new Line(v27, v30), -offset * 3 - pl, 0, dimensionStyle);
                dim16.UserText = "DCX = " + Math.Round(dcx / scale, 2);
                dxf.AddEntity(dim16);
            }
            if ((bdn + rcf * 2) > bdx && v33.Y > v9.Y && r>rcf)
            {
                double l = Math.Sqrt((v8.X - v44.X) * (v8.X - v44.X) + (v8.Y - v44.Y) * (v8.Y - v44.Y));
                double h = rcf - Math.Sqrt(rcf * rcf - l * l / 4);
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                Vector2[] Line3 = { v3, v4 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v4, v5 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v5, v6 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v6, v7 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                LwPolyline Arc7 = new LwPolyline();
                Arc7.Vertexes.Add(new LwPolylineVertex(v8));
                Arc7.Vertexes.Add(new LwPolylineVertex(v44));
                Arc7.Vertexes[0].Bulge = 2 * h / l;
                fun.PolyFill(dxf, Arc7, 0.3, contour);
                Vector2[] Line9 = { new Vector2(0,v33.Y), v33 };
                fun.drawBLine(dxf, Line9, 0.3, contour);
                Vector2[] Line10 = { v33, v34 };
                fun.drawBLine(dxf, Line10, 0.3, contour);
                /*Vector2[] Line11 = { v15, new Vector2(v15.X, v12.Y) };
                fun.drawBLine(dxf, Line11, 0.3, contour);*/
                Vector2[] Line12 = { v12, v20 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                LwPolyline Arc16 = new LwPolyline();
                Arc16.Vertexes.Add(new LwPolylineVertex(v20));
                Arc16.Vertexes.Add(new LwPolylineVertex(v19));
                Arc16.Vertexes[0].Bulge = 1;
                fun.PolyFill(dxf, Arc16, 0.3, contour);
                Vector2[] Line8 = { v18, v19 };
                fun.drawBLine(dxf, Line8, 0.3, contour);
                Vector2[] Line13 = { v27, v28 };
                fun.drawPlinetype(dxf, Line13, 0.15, refin, Linetype.Dashed);
                Vector2[] Line14 = { v28, v37 };
                fun.drawPlinetype(dxf, Line14, 0.15, refin, Linetype.Dashed);
                Vector2[] Line15 = { v37, v38 };
                fun.drawPlinetype(dxf, Line15, 0.15, refin, Linetype.Dashed);
                Vector2[] Line16 = { v39, v40 };
                fun.drawPlinetype(dxf, Line16, 0.15, refin, Linetype.Dashed);
                Vector2[] Line17 = { v21, v27 };
                fun.drawPlinetype(dxf, Line17, 0.15, refin, Linetype.Dashed);
                Vector2[] Line33 = { v40, v29 };
                fun.drawPlinetype(dxf, Line33, 0.15, refin, Linetype.Dashed);
                Vector2[] Line34 = { v29, v30 };
                fun.drawPlinetype(dxf, Line34, 0.15, refin, Linetype.Dashed);
                Vector2[] Line35 = { v30, v7 };
                fun.drawPlinetype(dxf, Line35, 0.15, refin, Linetype.Dashed);
                Vector2[] Line19 = { v17, v16 };
                fun.drawBLine(dxf, Line19, 0.3, contour);
                LwPolyline Arc17 = new LwPolyline();
                Arc17.Vertexes.Add(new LwPolylineVertex(v35));
                Arc17.Vertexes.Add(new LwPolylineVertex(v16));
                Arc17.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * Math.Cos(pi / 4) * 2;
                fun.PolyFill(dxf, Arc17, 0.3, contour);
                Vector2[] Line20 = { v15, v35 };
                fun.drawBLine(dxf, Line20, 0.3, contour);
                Vector2[] Line21 = { v21, v22 };
                fun.drawBLine(dxf, Line21, 0.3, contour);
                Vector2[] Line22 = { v22, v36 };
                fun.drawBLine(dxf, Line22, 0.3, contour);
                Vector2[] Line23 = { v36, v23 };
                fun.drawBLine(dxf, Line23, 0.3, contour);
                Vector2[] Line24 = { v23, v24 };
                fun.drawBLine(dxf, Line24, 0.3, contour);
                Vector2[] Line25 = { v24, v25 };
                fun.drawBLine(dxf, Line25, 0.3, contour);
                Vector2[] Line26 = { v25, v26 };
                fun.drawBLine(dxf, Line26, 0.3, contour);
                Vector2[] Line27 = { v26, v1 };
                fun.drawBLine(dxf, Line27, 0.3, contour);
                Vector2[] Line28 = { v25, new Vector2(0, v2.Y) };
                fun.drawBLine(dxf, Line28, 0.3, contour);
                Vector2[] Line29 = { v24, new Vector2(0, v3.Y) };
                fun.drawBLine(dxf, Line29, 0.3, contour);
                Vector2[] Line30 = { v36, new Vector2(0, v5.Y) };
                fun.drawBLine(dxf, Line30, 0.3, contour);
                Vector2[] Line31 = { v21, new Vector2(0, v18.Y) };
                fun.drawBLine(dxf, Line31, 0.3, contour);
                Vector2[] Line32 = { v31, v32 };
                fun.drawPlinetype(dxf, Line32, 0.15, center, Linetype.Center);
                Arc arc33 = new Arc(new Vector2(v8.X, v9.Y), rcf, 90, 180);
                Vector2[] Line36 = { v12, v7 };
                fun.drawBLine(dxf, Line36, 0.3, contour);
                Vector2[] Line37 = { v38, v18 };
                fun.drawPlinetype(dxf, Line37, 0.15, refin, Linetype.Dashed);
                Vector2[] Line38 = { v39, v12 };
                fun.drawPlinetype(dxf, Line38, 0.15, refin, Linetype.Dashed);
                //填充
                LwPolyline hatchpoly1 = new LwPolyline();
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v6));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v8));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v44));
                hatchpoly1.Vertexes[1].Bulge = 2 * h / l;
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v33));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(new Vector2(0, v33.Y)));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(new Vector2(0, 0)));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v1));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v2));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v3));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v4));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v5));
                hatchpoly1.IsClosed = true;
                String[] htype1 = new String[100];
                Line[] hline1 = new Line[100];
                Arc[] harc1 = new Arc[100];
                int hnumst1 = hatchpoly1.Explode().Count;  //记录爆炸后，线段有多少
                for (int i = 0; i < hnumst1; i++)
                {
                    htype1[i] = hatchpoly1.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                    if (htype1[i] == "Line")
                    {
                        hline1[i] = (Line)hatchpoly1.Explode()[i];
                    }
                    if (htype1[i] == "Arc")
                    {
                        harc1[i] = (Arc)hatchpoly1.Explode()[i];
                    }
                }
                fun.hatchsub1(dxf, htype1, hnumst1, 30, dconms / 2, hline1, harc1, hatching);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 1.0;
                double offset = 10;
                //线段尺寸标注
                //尺寸1
                LinearDimension dim1 = new LinearDimension(new Line(v4, v5), offset + v30.X - v4.X, 270, dimensionStyle);
                dim1.UserText = "FLGT = " + Math.Round(flgt / scale, 2);
                dxf.AddEntity(dim1);
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(v38, v39), -offset - pl, 0, dimensionStyle);
                dim2.UserText = "DCN = " + Math.Round(dcn / scale, 2);
                dxf.AddEntity(dim2);
                //尺寸4
                LinearDimension dim4 = new LinearDimension(new Line(v1, v3), offset * 3 + v30.X - (v3.X + v1.X) / 2, 270, dimensionStyle);
                dim4.UserText = "LS = " + Math.Round(ls / scale, 2);
                dxf.AddEntity(dim4);
                //尺寸5
                LinearDimension dim5 = new LinearDimension(new Line(v29, v1), offset * 4 + v30.X - (v29.X + v1.X) / 2, 270, dimensionStyle);
                dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                dxf.AddEntity(dim5);
                //尺寸6
                LinearDimension dim6 = new LinearDimension(new Line(v25, v2), offset + 0.5, 0, dimensionStyle);
                dim6.UserText = "DCONMS = " + Math.Round(dconms / scale, 2);
                dxf.AddEntity(dim6);
                //尺寸7
                LinearDimension dim7 = new LinearDimension(new Line(v23, v4), offset * 2 + ls, 0, dimensionStyle);
                dim7.UserText = "DF = " + Math.Round(df / scale, 2);
                dxf.AddEntity(dim7);
                //尺寸8
                LinearDimension dim8 = new LinearDimension(new Line(v22, v6), offset * 3 + ls + flgt, 0, dimensionStyle);
                dim8.UserText = "BDX = " + Math.Round(bdx / scale, 2);
                dxf.AddEntity(dim8);
                //尺寸9
                LinearDimension dim9 = new LinearDimension(new Line(v4, v29), offset * 3 + v30.X - (v4.X + v29.X) / 2, 270, dimensionStyle);
                dim9.UserText = "LPR = " + Math.Round(lpr / scale, 2);
                dxf.AddEntity(dim9);
                //尺寸10
                LinearDimension dim10 = new LinearDimension(new Line(v33, v34), offset + v30.X - v34.X, 270, dimensionStyle);
                dim10.UserText = "LB = " + Math.Round(lb / scale, 2);
                dxf.AddEntity(dim10);
                //尺寸11
                LinearDimension dim11 = new LinearDimension(new Line(v8, v29), offset * 2 + v30.X - (v8.X + v29.X) / 2, 270, dimensionStyle);
                dim11.UserText = "LCF = " + Math.Round(lcf / scale, 2);
                dxf.AddEntity(dim11);
                //尺寸12
                LinearDimension dim12 = new LinearDimension(new Line(v29, v30), offset + (v30.X - v29.X) / 2, 270, dimensionStyle);
                dim12.UserText = "PL = " + Math.Round(pl / scale, 2);
                dxf.AddEntity(dim12);
                //尺寸13
                RadialDimension dimrad13 = new RadialDimension(arc33, 135, -rcf, dimensionStyle);//DimensionStyle.Default);
                dimrad13.UserText = "RCF = " + Math.Round(rcf / scale, 2);
                dxf.AddEntity(dimrad13);
                //尺寸14
                Angular2LineDimension angdim14 = new Angular2LineDimension(new Line(v28, v27), new Line(v29, v30), v30.X / Math.Tan(sig / 2) + offset, dimensionStyle);
                angdim14.UserText = "SIG = " + Math.Round(sig / pi * 180, 2) + "°";
                dxf.AddEntity(angdim14);
                //尺寸15
                LinearDimension dim15 = new LinearDimension(new Line(v34, new Vector2(-v34.X, v34.Y)), -offset * 2 - pl, 0, dimensionStyle);
                dim15.UserText = "BDN = " + Math.Round(bdn / scale, 2);
                dxf.AddEntity(dim15);
                //尺寸16
                LinearDimension dim16 = new LinearDimension(new Line(v27, v30), -offset * 3 - pl, 0, dimensionStyle);
                dim16.UserText = "DCX = " + Math.Round(dcx / scale, 2);
                dxf.AddEntity(dim16);
            }
            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(-148.5, 210 - oal / 2));
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            //定义格式，根据路径导出

            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);


            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
        public static void TwistDrillsForDrillingBladesOrDrillingInserts(Dictionary<string, Object> data) //刀片钻削用麻花钻
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);
            //作图
            //参数
            string path = Convert.ToString(data["path"]);
            double soal = Convert.ToDouble(data["oal"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0 && soal < 67)
            {
                scale = 4.0;
            }
            else if (scale == 0 && soal < 90)
            {
                scale = 3.0;
            }
            else if (scale == 0 && soal < 134)
            {
                scale = 2.0;
            }
            else if (scale == 0 && soal < 178)
            {
                scale = 1.5;
            }
            else if (scale == 0 && soal < 268)
            {
                scale = 1.0;
            }
            else if (scale == 0 && soal < 357)
            {
                scale = 0.75;
            }
            else if (scale == 0)
            {
                scale = 0.5;
            }
            double pi = Math.PI;
            double bd = Convert.ToDouble(data["bd"]) * scale;
            double dc = Convert.ToDouble(data["dc"]) * scale;
            double dconms = Convert.ToDouble(data["dconms"]) * scale;
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double ls = Convert.ToDouble(data["ls"]) * scale;
            double df = Convert.ToDouble(data["df"]) * scale;
            double flgt = Convert.ToDouble(data["flgt"]) * scale;
            double lcf = Convert.ToDouble(data["lcf"]) * scale;
            double rcf = Convert.ToDouble(data["rcf"]) * scale;
            double sig = Convert.ToDouble(data["sig"]) * pi / 180;
            double latth = Convert.ToDouble(data["latth"]) * scale;
            double s1 = Convert.ToDouble(data["s1"]) * scale;
            double isframe = Convert.ToDouble(data["isframe"]);
            double pl = dc / 2 / Math.Tan(sig / 2);
            double lu = lcf - rcf;
            double lpr = oal - ls;
            //坐标
            //主视图
            Vector2 v1 = new Vector2(dconms / 2 - 0.5, 0);
            Vector2 v2 = new Vector2(v1.X + 0.5, -0.5);
            Vector2 v3 = new Vector2(v2.X, -ls);
            Vector2 v4 = new Vector2(df / 2, v3.Y);
            Vector2 v5 = new Vector2(v4.X, v4.Y - flgt);
            Vector2 v6 = new Vector2(bd / 2, v5.Y-(df-bd)/2);
            Vector2 v7 = new Vector2(v6.X, -ls-latth);
            Vector2 v8 = new Vector2(dc/2, v7.Y);
            Vector2 v9 = new Vector2(v8.X, -oal + pl);
            Vector2 v10 = new Vector2(0, -oal);
            Vector2 v11 = new Vector2(-v9.X, v9.Y);
            Vector2 v12 = new Vector2(-v8.X, v8.Y);
            Vector2 v13 = new Vector2(-v7.X, v7.Y);
            Vector2 v14 = new Vector2(-v6.X, v6.Y);
            Vector2 v15 = new Vector2(-v5.X, v5.Y);
            Vector2 v16 = new Vector2(-v4.X, v4.Y);
            Vector2 v17 = new Vector2(-v3.X, v3.Y);
            Vector2 v18 = new Vector2(-v2.X, v2.Y);
            Vector2 v19 = new Vector2(-v1.X, v1.Y);
            Vector2 v20 = new Vector2(-Math.Sqrt(bd * bd - s1 * s1) / 2, v11.Y);
            Vector2 v21 = new Vector2(v20.X+pl/2*Math.Tan(sig/2), v20.Y-pl/2);
            Vector2 v22 = new Vector2(-v21.X, v21.Y);
            Vector2 v23 = new Vector2(v5.X-rcf, v22.Y+(v5.X - rcf-v22.X)/Math.Tan(sig/2));
            Vector2 v24 = new Vector2(v23.X, v21.Y);
            Vector2 v25 = new Vector2(v24.X, v20.Y);
            Vector2 v26 = new Vector2(v25.X, v13.Y);
            Vector2 v27 = new Vector2(v26.X, -oal+lcf-rcf);
            double k = (v5.Y - v6.Y) / (v5.X - v6.X);
            double b = v5.Y - k * v5.X;
            double x = (-(k * b - v5.X - v27.Y * k) + Math.Sqrt((k * b - v5.X - v27.Y * k) * (k * b - v5.X - v27.Y * k) - (k * k + 1) * (v5.X * v5.X + b * b + v27.Y * v27.Y - 2 * v27.Y * b - rcf * rcf)))/(k*k+1);
            Vector2 v28 = new Vector2(x, k * x + b);
            Vector2 v32 = new Vector2(v6.X, -oal + lcf - rcf + Math.Sqrt(rcf * rcf - (v5.X - v6.X) * (v5.X - v6.X)));
            Vector2 v29 = new Vector2(0, 2);
            Vector2 v30 = new Vector2(0, -oal - 2);
            double c = v27.X;
            if (v27.Y < v14.Y)
            {
                c = v5.X-Math.Sqrt(rcf * rcf-(v14.Y - v27.Y) * (v14.Y - v27.Y));
            }
            Vector2 v31 = new Vector2(c, v14.Y);
            Vector2 v33 = new Vector2(v11.X, v10.Y * 2 - v11.Y);
            Vector2 v34 = new Vector2(v9.X, v10.Y * 2 - v9.Y);
            //线段
            //主视图
            Vector2[] Line1 = { v1, v2 };
            fun.drawBLine(dxf, Line1, 0.3, contour);
            Vector2[] Line2 = { v2, v3 };
            fun.drawBLine(dxf, Line2, 0.3, contour);
            Vector2[] Line3 = { v3, v4 };
            fun.drawBLine(dxf, Line3, 0.3, contour);
            Vector2[] Line4 = { v4, v5 };
            fun.drawBLine(dxf, Line4, 0.3, contour);
            Vector2[] Line5 = { v5, v6 };
            fun.drawBLine(dxf, Line5, 0.3, contour);
            Vector2[] Line6 = { v6, v7 };
            fun.drawBLine(dxf, Line6, 0.3, contour);
            Vector2[] Line7 = { v7, v8 };
            fun.drawBLine(dxf, Line7, 0.3, contour);
            Vector2[] Line8 = { v8, v9 };
            fun.drawBLine(dxf, Line8, 0.3, contour);
            Vector2[] Line9 = { v9, v10 };
            fun.drawBLine(dxf, Line9, 0.3, contour);
            Vector2[] Line10 = { v10, v11 };
            fun.drawBLine(dxf, Line10, 0.3, contour);
            Vector2[] Line11 = { v11, v12 };
            fun.drawBLine(dxf, Line11, 0.3, contour);
            Vector2[] Line12 = { v12, v13 };
            fun.drawBLine(dxf, Line12, 0.3, contour);
            Vector2[] Line13 = { v13, v14 };
            fun.drawBLine(dxf, Line13, 0.3, contour);
            Vector2[] Line14 = { v14, v15 };
            fun.drawBLine(dxf, Line14, 0.3, contour);
            Vector2[] Line15 = { v15, v16 };
            fun.drawBLine(dxf, Line15, 0.3, contour);
            if (v6.Y < (v27.Y + Math.Sqrt(rcf * rcf - (v5.X - v6.X) * (v5.X - v6.X))))
            {
                double l = Math.Sqrt((v28.X - v27.X) * (v28.X - v27.X) + (v28.Y - v27.Y) * (v28.Y - v27.Y));
                double h = rcf - Math.Sqrt(rcf * rcf - l * l / 4);
                LwPolyline Arc16 = new LwPolyline();
                Arc16.Vertexes.Add(new LwPolylineVertex(v28));
                Arc16.Vertexes.Add(new LwPolylineVertex(v27));
                Arc16.Vertexes[0].Bulge = 2 * h / l;
                fun.PolyFill(dxf, Arc16, 0.3, contour);
            }
            if (v6.Y >= (v27.Y + Math.Sqrt(rcf * rcf - (v5.X - v6.X) * (v5.X - v6.X))))
            {
                double l = Math.Sqrt((v32.X - v27.X) * (v32.X - v27.X) + (v32.Y - v27.Y) * (v32.Y - v27.Y));
                double h = rcf - Math.Sqrt(rcf * rcf - l * l / 4);
                LwPolyline Arc16 = new LwPolyline();
                Arc16.Vertexes.Add(new LwPolylineVertex(v32));
                Arc16.Vertexes.Add(new LwPolylineVertex(v27));
                Arc16.Vertexes[0].Bulge = 2 * h / l;
                fun.PolyFill(dxf, Arc16, 0.3, contour);
            }
            Vector2[] Line16 = { v16, v17 };
            fun.drawBLine(dxf, Line16, 0.3, contour);
            Vector2[] Line17 = { v17, v18 };
            fun.drawBLine(dxf, Line17, 0.3, contour);
            Vector2[] Line18 = { v18, v19 };
            fun.drawBLine(dxf, Line18, 0.3, contour);
            Vector2[] Line19 = { v19, v1 };
            fun.drawBLine(dxf, Line19, 0.3, contour);
            Vector2[] Line20 = { v18, v2 };
            fun.drawBLine(dxf, Line20, 0.3, contour);
            Vector2[] Line21 = { v17, v3 };
            fun.drawBLine(dxf, Line21, 0.3, contour);
            Vector2[] Line22 = { v15, v5 };
            fun.drawBLine(dxf, Line22, 0.3, contour);
            if (v6.Y < (v27.Y + Math.Sqrt(rcf * rcf - (v5.X - v6.X) * (v5.X - v6.X))))
            {
                Vector2[] Line23 = { v14, v31 };
                fun.drawBLine(dxf, Line23, 0.3, contour);
            }
            if (v6.Y >= (v27.Y + Math.Sqrt(rcf * rcf - (v5.X - v6.X) * (v5.X - v6.X))))
            {
                Vector2[] Line23 = { v14, v6 };
                fun.drawBLine(dxf, Line23, 0.3, contour);
            }
            Vector2[] Line24 = { v20, v25 };
            fun.drawBLine(dxf, Line24, 0.3, contour);
            Vector2[] Line25 = { v13, new Vector2(v20.X,v13.Y) };
            fun.drawBLine(dxf, Line25, 0.3, contour);
            Vector2[] Line26 = { new Vector2(v20.X,v13.Y), v20 };
            fun.drawBLine(dxf, Line26, 0.3, contour);
            Vector2[] Line27 = { v21, v20 };
            fun.drawBLine(dxf, Line27, 0.3, contour);
            if (v22.X<v24.X)
            {
                Vector2[] Line28 = { v21, v22 };
                fun.drawBLine(dxf, Line28, 0.3, contour);
                Vector2[] Line29 = { v22, v23 };
                fun.drawBLine(dxf, Line29, 0.3, contour);
                Vector2[] Line30 = { v23, v27 };
                fun.drawBLine(dxf, Line30, 0.3, contour);
            }
            if (v22.X >= v24.X)
            {
                Vector2[] Line28 = { v21, v24 };
                fun.drawBLine(dxf, Line28, 0.3, contour);
                Vector2[] Line29 = { v24, v27 };
                fun.drawBLine(dxf, Line29, 0.3, contour);
            }
            Vector2[] Line31 = { v26, v7 };
            fun.drawBLine(dxf, Line31, 0.3, contour);
            Vector2[] Line32 = { v29, v30 };
            fun.drawPlinetype(dxf, Line32, 0.15, center, Linetype.Center);
            Arc arc33 = new Arc(new Vector2(v5.X, v27.Y), rcf, 90, 180);
            Line Line34 = new Line(v10, v33);
            Line Line35 = new Line(v10, v34);
            Line34.Layer = dimensioning;
            Line35.Layer = dimensioning;
            dxf.AddEntity(Line34);
            dxf.AddEntity(Line35);
            //标注样式
            //箭头样式
            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 0.2;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            //文本样式
            dimensionStyle.TextHeight = 1.0;
            double offset = 10;
            //线段尺寸标注
            //尺寸1
            LinearDimension dim1 = new LinearDimension(new Line(v4, v5), offset, 270, dimensionStyle);
            dim1.UserText = "FLGT = " + Math.Round(flgt / scale, 2);
            dxf.AddEntity(dim1);
            //尺寸2
            LinearDimension dim2 = new LinearDimension(new Line(v11, v9), -offset * 3 - pl-10, 0, dimensionStyle);
            dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
            dxf.AddEntity(dim2);
            //尺寸3
            LinearDimension dim3 = new LinearDimension(new Line(v16, v12), -offset + (v16.X - v12.X) / 2, 270, dimensionStyle);
            dim3.UserText = "LATTH = " + Math.Round(latth / scale, 2);
            dxf.AddEntity(dim3);
            //尺寸4
            LinearDimension dim4 = new LinearDimension(new Line(v1, v3), offset + v4.X - v3.X+0.25, 270, dimensionStyle);
            dim4.UserText = "LS = " + Math.Round(ls / scale, 2);
            dxf.AddEntity(dim4);
            //尺寸5
            LinearDimension dim5 = new LinearDimension(new Line(v10, v1), offset * 5 + v4.X - v1.X / 2, 270, dimensionStyle);
            dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
            dxf.AddEntity(dim5);
            //尺寸6
            LinearDimension dim6 = new LinearDimension(new Line(v18, v2), offset + 0.5, 0, dimensionStyle);
            dim6.UserText = "DCONMS = " + Math.Round(dconms / scale, 2);
            dxf.AddEntity(dim6);
            //尺寸7
            LinearDimension dim7 = new LinearDimension(new Line(v16, v4), offset * 2 + v1.Y - v4.Y, 0, dimensionStyle);
            dim7.UserText = "DF = " + Math.Round(df / scale, 2);
            dxf.AddEntity(dim7);
            //尺寸8
            LinearDimension dim8 = new LinearDimension(new Line(v13, v7), -offset * 2 - v8.Y+v10.Y-10, 0, dimensionStyle);
            dim8.UserText = "BD = " + Math.Round(bd / scale, 2);
            dxf.AddEntity(dim8);
            //尺寸9
            LinearDimension dim9 = new LinearDimension(new Line(v4, v10), offset * 4 + v4.X / 2, 270, dimensionStyle);
            dim9.UserText = "LPR = " + Math.Round(lpr / scale, 2);
            dxf.AddEntity(dim9);
            //尺寸10
            LinearDimension dim10 = new LinearDimension(new Line(v27, v10), offset*2 - v27.X / 2 + v4.X, 270, dimensionStyle);
            dim10.UserText = "LU = " + Math.Round(lu / scale, 2);
            dxf.AddEntity(dim10);
            //尺寸11
            if (v6.Y < (v27.Y + Math.Sqrt(rcf * rcf - (v5.X - v6.X) * (v5.X - v6.X))))
            {
                LinearDimension dim11 = new LinearDimension(new Line(v10, v28), offset * 3 +v4.X- v28.X / 2, 270, dimensionStyle);
                dim11.UserText = "LCF = " + Math.Round(lcf / scale, 2);
                dxf.AddEntity(dim11);
            }
            if (v6.Y >= (v27.Y + Math.Sqrt(rcf * rcf - (v5.X - v6.X) * (v5.X - v6.X))))
            {
                LinearDimension dim11 = new LinearDimension(new Line(v10, v32), offset * 3 +v4.X- v32.X / 2, 270, dimensionStyle);
                dim11.UserText = "LCF = " + Math.Round(lcf / scale, 2);
                dxf.AddEntity(dim11);
            }
            //尺寸12
            LinearDimension dim12 = new LinearDimension(new Line(v9, v10), offset +v4.X- v9.X / 2, 270, dimensionStyle);
            dim12.UserText = "PL = " + Math.Round(pl / scale, 2);
            dxf.AddEntity(dim12);
            //尺寸13
            RadialDimension dimrad13 = new RadialDimension(arc33, 135, -rcf/2, dimensionStyle);//DimensionStyle.Default);
            dimrad13.UserText = "RCF = " + Math.Round(rcf / scale, 2);
            dxf.AddEntity(dimrad13);
            //尺寸14
            Angular2LineDimension angdim14 = new Angular2LineDimension(Line34, Line35, offset, dimensionStyle);
            angdim14.UserText = "SIG = " + Math.Round(sig / pi * 180, 2) + "°";
            dxf.AddEntity(angdim14);
            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(-148.5, 210 - oal / 2));
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            //定义格式，根据路径导出


            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);


            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
        public static void StepDrillForAdjustableSolidDrill(Dictionary<string, Object> data) //可调整体式阶梯钻
        {
            DxfDocument dxf = new DxfDocument();
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);


            //作图
            //参数
            string path = Convert.ToString(data["path"]);
            double soal = Convert.ToDouble(data["oal"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0 && soal < 67)
            {
                scale = 4.0;
            }
            else if (scale == 0 && soal < 90)
            {
                scale = 3.0;
            }
            else if (scale == 0 && soal < 134)
            {
                scale = 2.0;
            }
            else if (scale == 0 && soal < 178)
            {
                scale = 1.5;
            }
            else if (scale == 0 && soal < 268)
            {
                scale = 1.0;
            }
            else if (scale == 0 && soal < 357)
            {
                scale = 0.75;
            }
            else if (scale == 0)
            {
                scale = 0.5;
            }
            double pi = Math.PI;
            double bd = Convert.ToDouble(data["bd"]) * scale;
            double dc = Convert.ToDouble(data["dc"]) * scale;
            double dconms = Convert.ToDouble(data["dconms"]) * scale;
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double ls = Convert.ToDouble(data["ls"]) * scale;
            double df = Convert.ToDouble(data["df"]) * scale;
            double flgt = Convert.ToDouble(data["flgt"]) * scale;
            double lcf = Convert.ToDouble(data["lcf"]) * scale;
            double rcf = Convert.ToDouble(data["rcf"]) * scale;
            double sig = Convert.ToDouble(data["sig"]) * pi / 180;
            double adjl = Convert.ToDouble(data["adjl"]) * scale;
            double dconws = Convert.ToDouble(data["dconws"]) * scale;
            double isframe = Convert.ToDouble(data["isframe"]);
            double pl = Convert.ToDouble(data["pl"]) * scale;
            double lpr = oal - ls;
            //坐标
            //主视图
            Vector2 v1 = new Vector2(dconms / 2 - 0.5, 0);
            Vector2 v2 = new Vector2(v1.X + 0.5, -0.5);
            Vector2 v3 = new Vector2(v2.X, -ls);
            Vector2 v4 = new Vector2(df / 2, v3.Y);
            Vector2 v5 = new Vector2(v4.X, v4.Y - flgt);
            Vector2 v6 = new Vector2(bd / 2, v5.Y);
            Vector2 v8 = new Vector2(dconws/2, -oal);
            Vector2 v7 = new Vector2(v6.X, v8.Y+(v6.X-v8.X)/Math.Tan(sig/2));
            Vector2 v9 = new Vector2(-v8.X, v8.Y);
            Vector2 v10 = new Vector2(-v7.X, v7.Y);
            Vector2 v11 = new Vector2(-v6.X, v6.Y);
            Vector2 v12 = new Vector2(-v5.X, v5.Y);
            Vector2 v13 = new Vector2(-v4.X, v4.Y);
            Vector2 v14 = new Vector2(-v3.X, v3.Y);
            Vector2 v15 = new Vector2(-v2.X, v2.Y);
            Vector2 v16 = new Vector2(-v1.X, v1.Y);
            Vector2 v17 = new Vector2(v4.X-rcf, v8.Y);
            Vector2 v18 = new Vector2(v17.X, -oal+lcf-Math.Sqrt(rcf*rcf-(v4.X-v6.X)* (v4.X - v6.X)));
            Vector2 v19 = new Vector2(v6.X, -oal+lcf);
            double b = v17.X;
            if (v10.Y >= v18.Y)
            {
                b = v5.X - Math.Sqrt(rcf * rcf - (v10.Y - v18.Y) * (v10.Y - v18.Y));
            }
            Vector2 v20 = new Vector2(b, v10.Y);
            Vector2 v21 = new Vector2(-v17.X, v17.Y);
            Vector2 v22 = new Vector2(-v18.X, v18.Y);
            Vector2 v23 = new Vector2(-v19.X, v19.Y);
            Vector2 v24 = new Vector2(v8.X, v18.Y+ Math.Sqrt(rcf * rcf - (v4.X - v8.X) * (v4.X - v8.X)));
            Vector2 v25 = new Vector2(v24.X, v4.Y-adjl);
            Vector2 v26 = new Vector2(-v25.X, v25.Y);
            Vector2 v27 = new Vector2(0, 2);
            Vector2 v28 = new Vector2(0, -oal - 2);
            Vector2 v29 = new Vector2(v9.X, v8.Y-v8.X*2/ Math.Tan(sig / 2));
            Vector2 v30 = new Vector2(v8.X, v29.Y);
            double a = v18.X;
            if(v25.Y>=v18.Y&&v25.Y<=v19.Y)
            {
                a = v5.X - Math.Sqrt(rcf * rcf - (v25.Y - v18.Y) * (v25.Y - v18.Y));
            }
            Vector2 v31 = new Vector2(a, v25.Y);
            Vector2 v32 = new Vector2(v5.X- Math.Sqrt(rcf * rcf - (v8.Y - v18.Y) * (v8.Y - v18.Y)), v8.Y);
            Vector2 v33 = new Vector2(dc/2, v7.Y);
            Vector2 v34 = new Vector2(-v33.X, v33.Y);
            //线段
            //主视图
            Vector2[] Line1 = { v1, v2 };
            fun.drawBLine(dxf, Line1, 0.3, contour);
            Vector2[] Line2 = { v2, v3 };
            fun.drawBLine(dxf, Line2, 0.3, contour);
            Vector2[] Line3 = { v3, v4 };
            fun.drawBLine(dxf, Line3, 0.3, contour);
            Vector2[] Line4 = { v4, v5 };
            fun.drawBLine(dxf, Line4, 0.3, contour);
            Vector2[] Line5 = { v5, v6 };
            fun.drawBLine(dxf, Line5, 0.3, contour);
            Vector2[] Line6 = { v6, v7 };
            fun.drawBLine(dxf, Line6, 0.3, contour);
            Vector2[] Line7 = { v7, v8 };
            fun.drawBLine(dxf, Line7, 0.3, contour);
            Vector2[] Line8 = { v8, v9 };
            fun.drawBLine(dxf, Line8, 0.3, contour);
            Vector2[] Line9 = { v9, v10 };
            fun.drawBLine(dxf, Line9, 0.3, contour);
            Vector2[] Line10 = { v10, v11 };
            fun.drawBLine(dxf, Line10, 0.3, contour);
            Vector2[] Line11 = { v11, v12 };
            fun.drawBLine(dxf, Line11, 0.3, contour);
            Vector2[] Line12 = { v12, v13 };
            fun.drawBLine(dxf, Line12, 0.3, contour);
            Vector2[] Line13 = { v13, v14 };
            fun.drawBLine(dxf, Line13, 0.3, contour);
            Vector2[] Line14 = { v14, v15 };
            fun.drawBLine(dxf, Line14, 0.3, contour);
            Vector2[] Line15 = { v15, v16 };
            fun.drawBLine(dxf, Line15, 0.3, contour);
            Vector2[] Line16 = { v16, v1 };
            fun.drawBLine(dxf, Line16, 0.3, contour);
            Vector2[] Line17 = { v15, v2 };
            fun.drawBLine(dxf, Line17, 0.3, contour);
            Vector2[] Line18 = { v14, v3 };
            fun.drawBLine(dxf, Line18, 0.3, contour);
            Vector2[] Line19 = { v11, v6 };
            fun.drawBLine(dxf, Line19, 0.3, contour);
            Vector2[] Line20 = { v10, v20 };
            fun.drawBLine(dxf, Line20, 0.3, contour);
            if (v25.Y >= v24.Y)
            {
                Vector2[] Line22 = { v24, v25 };
                fun.drawPlinetype(dxf, Line22, 0.15, refin, Linetype.Dashed);
                Vector2[] Line26 = { v8, v24 };
                fun.drawBLine(dxf, Line26, 0.3, contour);
                Vector2[] Line23 = { v25, v26 };
                fun.drawPlinetype(dxf, Line23, 0.15, refin, Linetype.Dashed);
            }
            if (v25.Y < v24.Y)
            {
                Vector2[] Line22 = { v31, v26 };
                fun.drawPlinetype(dxf, Line22, 0.15, refin, Linetype.Dashed);
                Vector2[] Line26 = { v25, v31 };
                fun.drawBLine(dxf, Line26, 0.3, contour);
                Vector2[] Line33 = { v8, v25 };
                fun.drawBLine(dxf, Line33, 0.3, contour);
            }
            Vector2[] Line24 = { v26, v9 };
            fun.drawPlinetype(dxf, Line24, 0.15, refin, Linetype.Dashed);
            Vector2[] Line27 = { v27, v28 };
            fun.drawPlinetype(dxf, Line27, 0.15, center, Linetype.Center);
            Arc arc30 = new Arc(new Vector2(v5.X, v18.Y), rcf, 90, 180);
            if (lcf >= (v19.Y - v18.Y))
            {
                double l = Math.Sqrt((v19.X - v18.X) * (v19.X - v18.X) + (v19.Y - v18.Y) * (v19.Y - v18.Y));
                double h = rcf - Math.Sqrt(rcf * rcf - l * l / 4);
                LwPolyline Arc31 = new LwPolyline();
                Arc31.Vertexes.Add(new LwPolylineVertex(v19));
                Arc31.Vertexes.Add(new LwPolylineVertex(v18));
                Arc31.Vertexes[0].Bulge = 2 * h / l;
                fun.PolyFill(dxf, Arc31, 0.3, contour);
                Vector2[] Line21 = { v17, v18 };
                fun.drawBLine(dxf, Line21, 0.3, contour);
                Arc arc32 = new Arc(new Vector2(v12.X, v22.Y), rcf, 0, Math.Atan((v23.Y - v22.Y) / (v11.X - v12.X)) / pi * 180);
                arc32.Layer = refin;
                arc32.Linetype = Linetype.Dashed;
                dxf.AddEntity(arc32);
                Vector2[] Line25 = { v21, v22 };
                fun.drawPlinetype(dxf, Line25, 0.15, refin, Linetype.Dashed);
            }
            Arc arc33 = new Arc(new Vector2(v5.X, v18.Y), rcf, 90 + Math.Atan((v5.X - v19.X) / (v19.Y - v18.Y)) / pi * 180, 180 - Math.Atan((v32.Y - v18.Y) / (v5.X - v32.X)) / pi * 180);
            if (lcf < (v19.Y - v18.Y))
            {
                double l = Math.Sqrt((v19.X - v32.X) * (v19.X - v32.X) + (v19.Y - v32.Y) * (v19.Y - v32.Y));
                double h = rcf - Math.Sqrt(rcf * rcf - l * l / 4);
                LwPolyline Arc31 = new LwPolyline();
                Arc31.Vertexes.Add(new LwPolylineVertex(v19));
                Arc31.Vertexes.Add(new LwPolylineVertex(v32));
                Arc31.Vertexes[0].Bulge = 2 * h / l;
                fun.PolyFill(dxf, Arc31, 0.3, contour);
                Arc arc32 = new Arc(new Vector2(v12.X, v18.Y), rcf, Math.Atan((v32.Y - v18.Y) / (v5.X - v32.X)) / pi * 180, 90 - Math.Atan((v5.X - v19.X) / (v19.Y - v18.Y)) / pi * 180);
                arc32.Layer = refin;
                arc32.Linetype = Linetype.Dashed;
                dxf.AddEntity(arc32);
            }
            Line Line28 = new Line(v8, v29);
            Line Line29 = new Line(v9, v30);
            Line28.Layer = dimensioning;
            Line29.Layer = dimensioning;
            dxf.AddEntity(Line28);
            dxf.AddEntity(Line29);
            Vector2[] Line34 = { v7, v33 };
            fun.drawPlinetype(dxf, Line34, 0.15, refin, Linetype.Dashed);
            Vector2[] Line35 = { v33, v8 };
            fun.drawPlinetype(dxf, Line35, 0.15, refin, Linetype.Dashed);
            Vector2[] Line36 = { v10, v34 };
            fun.drawPlinetype(dxf, Line36, 0.15, refin, Linetype.Dashed);
            Vector2[] Line37 = { v34, v9 };
            fun.drawPlinetype(dxf, Line37, 0.15, refin, Linetype.Dashed);
            //标注样式
            //箭头样式
            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 0.2;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            //文本样式
            dimensionStyle.TextHeight = 1.0;
            double offset = 10;
            //线段尺寸标注
            //尺寸1
            LinearDimension dim1 = new LinearDimension(new Line(v4, v5), offset, 270, dimensionStyle);
            dim1.UserText = "FLGT = " + Math.Round(flgt / scale, 2);
            dxf.AddEntity(dim1);
            //尺寸2
            LinearDimension dim2 = new LinearDimension(new Line(v34, v33), -offset * 5 - pl-10, 0, dimensionStyle);
            dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
            dxf.AddEntity(dim2);
            //尺寸3
            LinearDimension dim3 = new LinearDimension(new Line(v13, v26), -offset - (v26.X - v13.X) / 2, 270, dimensionStyle);
            dim3.UserText = "ADJL = " + Math.Round(adjl / scale, 2);
            dxf.AddEntity(dim3);
            //尺寸4
            LinearDimension dim4 = new LinearDimension(new Line(v1, v3), offset + v4.X - v3.X + 0.25, 270, dimensionStyle);
            dim4.UserText = "LS = " + Math.Round(ls / scale, 2);
            dxf.AddEntity(dim4);
            //尺寸5
            LinearDimension dim5 = new LinearDimension(new Line(v8, v1), offset * 4 + v4.X - (v1.X+v8.X) / 2, 270, dimensionStyle);
            dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
            dxf.AddEntity(dim5);
            //尺寸6
            LinearDimension dim6 = new LinearDimension(new Line(v15, v2), offset + 0.5, 0, dimensionStyle);
            dim6.UserText = "DCONMS = " + Math.Round(dconms / scale, 2);
            dxf.AddEntity(dim6);
            //尺寸7
            LinearDimension dim7 = new LinearDimension(new Line(v13, v4), offset * 2 + v1.Y - v4.Y, 0, dimensionStyle);
            dim7.UserText = "DF = " + Math.Round(df / scale, 2);
            dxf.AddEntity(dim7);
            //尺寸8
            LinearDimension dim8 = new LinearDimension(new Line(v10, v7), -offset * 4 - v7.Y + v8.Y-10, 0, dimensionStyle);
            dim8.UserText = "BD = " + Math.Round(bd / scale, 2);
            dxf.AddEntity(dim8);
            //尺寸9
            LinearDimension dim9 = new LinearDimension(new Line(v4, v8), offset * 3 + (v4.X-v8.X) / 2, 270, dimensionStyle);
            dim9.UserText = "LPR = " + Math.Round(lpr / scale, 2);
            dxf.AddEntity(dim9);
            /*//尺寸10
            LinearDimension dim10 = new LinearDimension(new Line(v27, v10), offset * 2 - v27.X / 2 + v4.X, 270, dimensionStyle);
            dim10.UserText = "LU = " + Math.Round(lu / scale, 2);
            dxf.AddEntity(dim10);*/
            //尺寸11
            LinearDimension dim11 = new LinearDimension(new Line(v19, v8), offset * 2 + v4.X - (v19.X + v8.X) / 2, 270, dimensionStyle);
            dim11.UserText = "LCF = " + Math.Round(lcf / scale, 2);
            dxf.AddEntity(dim11);
            //尺寸12
            LinearDimension dim12 = new LinearDimension(new Line(v8, v33), offset + v4.X - (v33.X+v8.X)/ 2, 270, dimensionStyle);
            dim12.UserText = "PL = " + Math.Round(pl / scale, 2);
            dxf.AddEntity(dim12);
            /*//尺寸13
            RadialDimension dimrad13 = new RadialDimension(arc32, 135, -rcf / 2, dimensionStyle);//DimensionStyle.Default);
            dimrad13.UserText = "RCF = " + Math.Round(rcf / scale, 2);
            dxf.AddEntity(dimrad13);*/
            //尺寸14
            Angular2LineDimension angdim14 = new Angular2LineDimension(Line28, Line29, offset, dimensionStyle);
            angdim14.UserText = "SIG = " + Math.Round(sig / pi * 180, 2) + "°";
            dxf.AddEntity(angdim14);
            //尺寸15
            LinearDimension dim15 = new LinearDimension(new Line(v8, v9), -offset * 3-10, 0, dimensionStyle);
            dim15.UserText = "DCONWS = " + Math.Round(dconws / scale, 2);
            dxf.AddEntity(dim15);
            //尺寸16
            if (lcf >= (v19.Y - v18.Y))
            {
                RadialDimension dimrad16 = new RadialDimension(arc30, 135, -rcf + 5, dimensionStyle);//DimensionStyle.Default);
                dimrad16.UserText = "RCF = " + Math.Round(rcf / scale, 2);
                dxf.AddEntity(dimrad16);
            }
            if (lcf < (v19.Y - v18.Y))
            {
                RadialDimension dimrad16 = new RadialDimension(arc33, 135, -rcf + 5, dimensionStyle);//DimensionStyle.Default);
                dimrad16.UserText = "RCF = " + Math.Round(rcf / scale, 2);
                dxf.AddEntity(dimrad16);
            }
            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(-148.5, 210 - oal / 2));
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            //定义格式，根据路径导出



            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
    }
}
